Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BROWSER command launches wrong browser.

17 REPLIES 17
Reply
Message 1 of 18
FT398
2981 Views, 17 Replies

BROWSER command launches wrong browser.

How does AutoCAD determine which browser to fire up when using the 'browser' command? I assumed it would use the default Windows browser but we are finding that not to be the case, unless you only have one browser installed. However, a few of us here have two browsers installed (Firefox and IE9) and despite us all having IE9 set as the default browser, AutoCAD always launches Firefox when we use the browser command.

 

Any ideas?

17 REPLIES 17
Message 2 of 18
TomBeauford
in reply to: FT398

AutoCAD browser command always opens Chrome here, IE11 is set as default. Must be set somewhere in the registry.
64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
Message 3 of 18
paullimapa
in reply to: FT398

The way I've gottend around this is to define a new lisp function calling IE specifically to open a given URL.

The drawback is that since it uses the SHELL command, you'll have to close the DOS box after the command runs.

But I've added into the new IE.lsp routine the ability to save the previous URL entered so it's not always defaulting to autodesk's website.

 

; ie.lsp will open given link using Internet Explorer Browser
(princ"\nLoading IE command...")(princ)
(defun c:ie (/ lnk)
 (if (not aec_url)(setq aec_url "www.autodesk.com"))
 (setq lnk (getstring(strcat"\nEnter Web location URL <" aec_url ">: ")))
 (if (= lnk "")(setq lnk aec_url)(setq aec_url lnk))
 (princ (strcat "\nOpening URL " lnk " with IE Browser.\n"))(princ)
 (setq lnk (strcat (chr 34)(getenv"ProgramFiles")"\\Internet Explorer\\iexplore.exe"(chr 34) " " lnk))
 (command "_.Shell" lnk)(princ)
) ; defun
(princ"\n..loaded.")(princ)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 18
Lee_Mac
in reply to: paullimapa

Another option might be to interface with the Internet Explorer Application directly using ActiveX, e.g.:

 

(defun navigateto ( url / ie )
    (if (setq ie (vlax-get-or-create-object "internetexplorer.application"))
        (progn
            (vl-catch-all-apply
               '(lambda nil
                    (vlax-invoke-method ie 'navigate url)
                    (vlax-put-property  ie 'visible :vlax-true)
                )
            )
            (vlax-release-object ie)
            url
        )
    )
)
(vl-load-com) (princ)

 

Call with the target url, e.g.:

 

(navigateto "http://www.google.com")

 

Message 5 of 18
paullimapa
in reply to: Lee_Mac

This is actually a very nice way of tackling this problem. But when I invoke the function, the IE browser window does NOT come up on top to become the active window.  Instead I only see the application blinking on the Windows Launch bar.  I would have to select it to get it to show on top.  Is there a way to bring the IE browser app to the top window?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 18
hmsilva
in reply to: paullimapa


@paullimapa wrote:

The way I've gottend around this is to define a new lisp function calling IE specifically to open a given URL.

The drawback is that since it uses the SHELL command, you'll have to close the DOS box after the command runs.

But I've added into the new IE.lsp routine the ability to save the previous URL entered so it's not always defaulting to autodesk's website.


Hi Paul Li,

it's a nice program to replace the "BROWSER" command, but if you change the

 (command "_.Shell" lnk)

to

(startapp lnk)

we'll get a silent load and we will not have to worry about the DOS box...

 

Henrique

 

EESignature

Message 7 of 18
Lee_Mac
in reply to: paullimapa

pli wrote:

This is actually a very nice way of tackling this problem. But when I invoke the function, the IE browser window does NOT come up on top to become the active window.  Instead I only see the application blinking on the Windows Launch bar.  I would have to select it to get it to show on top.  Is there a way to bring the IE browser app to the top window?

 

This is probably not the best way to tackle it, but it should work:

 

(defun navigateto ( url / ie )
    (if (setq ie (vlax-get-or-create-object "internetexplorer.application"))
        (progn
            (vl-catch-all-apply
               '(lambda nil
                    (vlax-invoke-method ie 'navigate url)
                    (vlax-put-property  ie 'visible :vlax-true)
                )
            )
            (vlax-release-object ie)
            (LM:appactivate "Internet Explorer")
            url
        )
    )
)

;; App Activate  -  Lee Mac
;; A wrapper for the appactivate method of the WSH
;; str - [str] Application title or Process ID

(defun LM:appactivate ( str / rtn wsh )
    (if (setq wsh (vlax-create-object "wscript.shell"))
        (progn
            (setq rtn (vl-catch-all-apply 'vlax-invoke-method (list wsh 'appactivate str)))
            (vlax-release-object wsh)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                rtn
            )
        )
    )
)
(vl-load-com) (princ)

 

Message 8 of 18
paullimapa
in reply to: hmsilva

(startapp) function is perfect...thanks for this solution.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 18
paullimapa
in reply to: Lee_Mac

LM:appactivate function is pretty good.  But it's inconsistant for me...sometimes the IE window appear on top.  Then there will be times when it'll appear on top and then disappear and acad will be the active window again.

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 10 of 18
hmsilva
in reply to: paullimapa


@paullimapa wrote:

(startapp) function is perfect...thanks for this solution.


You're welcome, Paul Li
Glad I could help

 

Henrique

EESignature

Message 11 of 18
Lee_Mac
in reply to: paullimapa

pli wrote:

LM:appactivate function is pretty good. But it's inconsistant for me...sometimes the IE window appear on top. Then there will be times when it'll appear on top and then disappear and acad will be the active window again.

 

Yes I agree, it's not an ideal solution.

Message 12 of 18
tuomo.jarvinen
in reply to: Lee_Mac

Hi, I used to use (command "browser" (getvar "dwgprefix")) to go directly to the folder I was in. Worked fine until I set Chrome to my default browser with known results.. Changed it quickly back to IE but no awail.. Have no rights to edit registry... Added "navigateto" (thanks for that!) to my acaddoc.lsp ja edited all my lisps using "browser" - command to use "navigateto". Can open folders again, but... is there a way to prevent IE to open a blank page? 

Message 13 of 18
kevinjackman
in reply to: paullimapa

Hi Paul,

I'm trying to implement your LISP to start IE, at a target URL, as you've described. The LISP routine runs fine.

 

The problem I am having is when running two separate LSP's, each with different URL targets.

 

It seems that the AEC_URL is defined by the first LSP that is loaded. If a second LSP is called, the AEC_URL isn't being overwritten with the new target URL, and as such, the target URL defaults to the initial URL.

 

Do you have any solution for this? I've attach both LSP files.

 

Thanks a lot.

 

Kevin Jackman

Tags (3)
Message 14 of 18

I believe the code is fine. You just need to localize aec_url

(defun c:RedDeerGuidelines (/ lnk aec_url)
..............
(defun c:RedDeerSpecs (/ lnk aec_url)
...........
Message 15 of 18
paullimapa
in reply to: kevinjackman

If you want to set a different URL, then you'll have to remove this part of the code:

(if (not aec_url)

 

In both cases, you just set the URL to what you want:

(setq aec_url "www.reddeer.ca/media/reddeerca/city-services/engineering/publications/Contract-Specs-PDF.pdf")

or

(setq aec_url "www.reddeer.ca/media/reddeerca/city-services/engineering/publications/Design-Guidelines-Full-Version...")

 

See attached revised lisp files.

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 16 of 18

Worked perfectly! Thanks Ranjit and Paul!

Message 17 of 18
kevinjackman
in reply to: paullimapa

And for my next question - is there a way to avoid the user input and go directly to the URL? Currently the user must hit Enter to accept the default URL.

 

Thanks!

Message 18 of 18
paullimapa
in reply to: kevinjackman

Sure, you just need to remove any request for input and set lnk directly to the URL addresses.

See revised lisp code in zip.

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost