vladedoty Posted April 6, 2010 Share Posted April 6, 2010 Is there a way to make a clickable link in a msgbox? Link to comment Share on other sites More sharing options...
blakel Posted April 6, 2010 Share Posted April 6, 2010 (edited) Doubt it.You can if you use a GUI. I have done this several times; I like to link to the manual with this method.Create a label,$aLabel = GUICtrlCreateLabel()Use GUICtrlSetFont to change the color to blue and underline it. (So the user will know to click on it.)Listen for it to be clicked with GetGetMsg, like a button.Then use Run to run IE. I think there is also a registry value to tell you which browser is default.I am not sure if you can or how to use ShellExecute for a URL.I think that is how. I will check later if that does not work for you.Edit:GUICtrlSetFont($aLabel,-1,-1,4)GUICtrlSetColor($aLabel,0x0000cc)GUICtrlSetCursor($aLabel,0) Edited April 7, 2010 by blakel Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 7, 2010 Share Posted April 7, 2010 Once they click on your link (label), it would be better to open it this way: $sURL = "http://www.autoitscript.com" ShellExecute($sURL) That leaves it up to the user's default browser selection to open the link. You never know, it might be a Firefox, Chrome, or Opera fanatic who would be insulted by forcing IE on them! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Euler G. Posted March 15, 2011 Share Posted March 15, 2011 Once they click on your link (label), it would be better to open it this way: $sURL = "http://www.autoitscript.com" ShellExecute($sURL) That leaves it up to the user's default browser selection to open the link. You never know, it might be a Firefox, Chrome, or Opera fanatic who would be insulted by forcing IE on them! Hi! I'm facing this problem right now, trying to make my script "default browser" compliant. Strangely, it works very well when using <IE.au3> functions but fails when using functions that call default applications. While opening a link with _IECreate($sLink) works just fine, it doesn't (in part) when using either ShellExecute($sLink, "", "", "open", @SW_HIDE) or Run(@ComSpec & ' /c start "" ' & $sLink, '', @SW_HIDE). I said "partly" because both Run() and ShellExecute() open link into application (Firefox, in my case) but I get an error message, as shown below. Only IECreate() opens link smoothly, but there are those who hate IE so deeply... I'm using WinXP SP3. I'm certainly I'm doing something wrong. I only would like to know what. Below a test snippet. #include <INet.au3> #include <IE.au3> $sPayPal = "http://www.yahoo.com/" _Start($sPayPal) ShellExecute($sPayPal, "", "", "open", @SW_SHOW) _IECreate($sPayPal) Exit Func _Start($s_StartPath) ; from AutoUpdateIt.au3 Local $s_StartStr If @OSType = 'WIN32_NT' Then $s_StartStr = @ComSpec & ' /c start "" ' Else $s_StartStr = @ComSpec & ' /c start ' EndIf Run($s_StartStr & $s_StartPath, '', @SW_HIDE) EndFunc ;==>_Start Thanks in advance for any help. Best, Euler Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 15, 2011 Share Posted March 15, 2011 Not sure what you are trying to do with the _Start() function. But according to PSalty's post, $sPayPal = "http://www.yahoo.com/" ShellExecute($sPayPal) Should work just fine. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Euler G. Posted March 15, 2011 Share Posted March 15, 2011 Not sure what you are trying to do with the _Start() function.But according to PSalty's post,$sPayPal = "http://www.yahoo.com/"ShellExecute($sPayPal)Should work just fine.It does, but Windows pops those two error dialogs. That's bugging me. Best, Euler Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 15, 2011 Share Posted March 15, 2011 Odd because I just used that exact 2 line code here with no errors... is there more you are adding which is causing errors or perhaps something with your default browser? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Euler G. Posted March 15, 2011 Share Posted March 15, 2011 Nope, and I'm running out of clues. I have the code above ran in all my boxes. I'll try to run it on a Dell laptop from a friend of mine just to see if it behaves differently. All of my boxes have Firefox v3.6.15 as default Internet browser and I have the same weirdness in all. Maybe I should try installing Opera o Chrome just to see if it changes anything. <sigh> Best, Euler Link to comment Share on other sites More sharing options...
Carlo84 Posted March 15, 2011 Share Posted March 15, 2011 (edited) Odd because I just used that exact 2 line code here with no errors... is there more you are adding which is causing errors or perhaps something with your default browser? yeah think you have a browser issue, do you get this error also when you open a http shortcut by hand? if so check the value of "HKEY_CLASSES_ROOT\http\shell\open\command" in the registry. Looking at the screenshots, it looks like Explorer is attempting to open the http location instead of iExplorer [Edit] your code worked fine for me btw, with Firefox 3.6.13 as default browser. Edited March 15, 2011 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Euler G. Posted March 26, 2011 Share Posted March 26, 2011 Checked Registry. This is the value there: "C:\Program Files\Mozilla Firefox\firefox.exe" -requestPending -osint -url "%1". Looks standard Firefox. Best, Euler Link to comment Share on other sites More sharing options...
BrewManNH Posted March 26, 2011 Share Posted March 26, 2011 If you open Start Menu ->Run and type in http://www.yahoo.com/ what happens? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Euler G. Posted March 27, 2011 Share Posted March 27, 2011 Yahoo! website opens in Firefox (default browser), as it should be. I'd expect the same behavior from AutoIt script, no more, no less. Best, Euler Link to comment Share on other sites More sharing options...
BrewManNH Posted March 27, 2011 Share Posted March 27, 2011 I ran the test script and it opened Firefox and IE and then went to Yahoo. I then tried it with Chrome set as the default and it opened Chrome and then IE, so it's not AutoIt or the script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Euler G. Posted March 27, 2011 Share Posted March 27, 2011 Must be something else. I have to dig on it to find out, starting by running it on other machines. Thanks anyway for your insights. Best, Euler Link to comment Share on other sites More sharing options...
wolf9228 Posted March 28, 2011 Share Posted March 28, 2011 (edited) Is there a way to make a clickable link in a msgbox? expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $TestHover = False GUICreate("Custom Msgbox", 210, 80) $Label1 = GUICtrlCreateLabel("http://www.autoitscript.com", 10, 10, 188, 22,$SS_NOTIFY) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0xff0000) $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20) $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUISetState() Do LinkHover($Label1) $msg = GUIGetMsg() Select Case $msg = $YesID MsgBox(0, "You clicked on", "Yes") Case $msg = $NoID MsgBox(0, "You clicked on", "No") Case $msg = $ExitID MsgBox(0, "You clicked on", "Exit") Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "You clicked on", "Close") Case $msg = $Label1 ShellExecute("http://www.autoitscript.com") EndSelect Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID Func LinkHover($controlID) $WPos = WinGetPos(GUICtrlGetHandle($controlID)) $MPos = MouseGetPos() if IsArray($WPos) And IsArray($MPos) Then $X = $MPos[0] $Y = $MPos[1] $L = $WPos[0] $T = $WPos[1] $W = $WPos[2] $H = $WPos[3] if ($X >= $L And $X <= ($L + $W) And $Y >= $T And $Y <= ($T + $H)) Then if $TestHover = False Then $TestHover = True GUICtrlSetColor($controlID, 0x008080) GUICtrlSetCursor($controlID, 0) EndIf Else if $TestHover = True Then GUICtrlSetColor($controlID, 0xff0000) $TestHover = False EndIf EndIf EndIf EndFunc Edited November 9, 2014 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Euler G. Posted March 28, 2011 Share Posted March 28, 2011 After wolf9228 post above I realized that I should NOT provide parameters where they are not expected. All I had to do is provide the whole link string (it's a bit long, BTW) to shellexecute() function and all did well. At least for me this shellexecute() thing is solved. Tomorrow there's more problems to solve in other area.Thanks to all! Best, Euler 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