billmez Posted February 16, 2006 Share Posted February 16, 2006 Hi all, Is the following code the best way to handle opening a URL in the user's default browser, or does anyone have a more sure way. The reg value here comes from XP pro, and I'm not sure if it applys to other OSes, or if the %1 parameter would apply to other browser types. $regVal = RegRead("HKEY_CLASSES_ROOT\InternetShortcut\shell\open\command", "") $regVal = StringReplace($regVal, "%1", "http://www.wpde.com/") Run($regVal) Thanks for the input, billmez Link to comment Share on other sites More sharing options...
cdkid Posted February 16, 2006 Share Posted February 16, 2006 umm what about Run(@comspec & " /c start www.wpde.com",@scriptdir, @SW_HIDE) --maybe? ~cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
billmez Posted February 16, 2006 Author Share Posted February 16, 2006 umm what about Run(@comspec & " /c start www.wpde.com",@scriptdir, @SW_HIDE) --maybe? ~cdkid I tried that also and it too worked. I question whether opening a hidden command shell is a better way to handle it than reading the reg key and running the default browser directly. That's why I am asking for advice here. I would appreciate your thoughts on the +/- or both ways. Thanks, billmez Link to comment Share on other sites More sharing options...
cdkid Posted February 16, 2006 Share Posted February 16, 2006 personally, i prefer using a hidden cmd window cuz that's surefire... i dont know if all OSes have that reg key, so that's just the way i'd go. seems more reliable to me ~cdkid has spoken AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 16, 2006 Moderators Share Posted February 16, 2006 I use the one in my signature 99% of the time with 2 back ups in case it fails. If the url string has '%' in it I use: Local $u_URL_LINK = 'www.yourlink.com/ALPHATEST/return=http%3a%2f%2fyourreturnurl%2ecom' Local $OpenUrl = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\https\shell\open\command", "") Local $UrlSplit = StringSplit($OpenUrl, '%') If IsArray($UrlSplit) And UBound($UrlSplit) - 1 = 2 Then Local $SendUrl = $UrlSplit[1] & $u_URL_LINK & StringTrimLeft($UrlSplit[2], 1) Run($SendUrl) EndIf If it does not have a '%' in the string , and my signature DLLCall one has failed, I use: Run(@ComSpec & " /c Start " & $u_URL_LINK, "", @SW_HIDE) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
billmez Posted February 17, 2006 Author Share Posted February 17, 2006 I use the one in my signature 99% of the time with 2 back ups in case it fails. If the url string has '%' in it I use: Local $u_URL_LINK = 'www.yourlink.com/ALPHATEST/return=http%3a%2f%2fyourreturnurl%2ecom' Local $OpenUrl = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\https\shell\open\command", "") Local $UrlSplit = StringSplit($OpenUrl, '%') If IsArray($UrlSplit) And UBound($UrlSplit) - 1 = 2 Then Local $SendUrl = $UrlSplit[1] & $u_URL_LINK & StringTrimLeft($UrlSplit[2], 1) Run($SendUrl) EndIf If it does not have a '%' in the string , and my signature DLLCall one has failed, I use: Run(@ComSpec & " /c Start " & $u_URL_LINK, "", @SW_HIDE) Thanks for the response What are the benefits of using the dll call method over the regread version, and what OSes/browsers does it fail on? Also, am I missing something or isn't this just an empty string? StringTrimLeft($UrlSplit[2], 1) And if it is,why are you using it there. billmez Link to comment Share on other sites More sharing options...
eltorro Posted February 17, 2006 Share Posted February 17, 2006 $url="http://www.autoitscript.com" run("RunDLL32.EXE url.dll,FileProtocolHandler "&$url) Steve Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
billmez Posted February 18, 2006 Author Share Posted February 18, 2006 $url="http://www.autoitscript.com" run("RunDLL32.EXE url.dll,FileProtocolHandler "&$url) Steve Will this also work on Win98 and with default browsers other than IE? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now