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?
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)
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")
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?
@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
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)
(startapp) function is perfect...thanks for this solution.
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.
@paullimapa wrote:
(startapp) function is perfect...thanks for this solution.
You're welcome, Paul Li
Glad I could help
Henrique
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.
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?
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
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) ...........
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
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!
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
Can't find what you're looking for? Ask the community or share your knowledge.