Jump to content

Link to URL with Static Label


Recommended Posts

I apologize in advance if this is covered elsewhere. I have literally spent hours combing through the search engine and other user examples to find this answer.

How can I make some text on my About window be a hotlink to a URL?

The following is part of the script I am trying to run.

Case $ctrlmsg = $aboutitem
      $winpos = WinGetPos ("Numerimal")
      $childgui = GUICreate ("About Numerimal", 260, 85, $winpos[0] + 10, $winpos[1] + 10, BitOr($WS_POPUP, $WS_CAPTION, $WS_SYSMENU), -1, $parentgui)
      GUISetState (@SW_SHOW)
      GUICtrlCreateLabel ("Numerimal Version 0.1.0" & chr(10) & chr(10) & "Copyright " & chr(169) & " 2004 Xyntec Inc.", 62, 10, 150, 75, $SS_CENTER)
      $xynteclink = GUICtrlCreateLabel ("http://www.xyntec.com", 62, 60, 150, 75, BitOR($BS_FLAT, $BS_CENTER)); THIS IS THE TEXT I WANT TO LINK TO A WEBSITE
      GUISwitch ($parentgui)
      GUISetState (@SW_DISABLE)

    Case $ctrlmsg = $xynteclink
      DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", "", "string", "http://www.xyntec.com/", "string", "", "string", "", "long", @SW_SHOWNORMAL)      

 OR

    Case $ctrlmsg = $xynteclink
      $defaultBrowser = StringSplit(RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", ""), " ")
      Run($defaultBrowser[1] & " http://www.autoit3.com/")

Currently, I try to open the About window and the script just continually opens the link until I use ALT+F4

Please Help :)

Edited by NewKreation
Link to comment
Share on other sites

I'm sure there is a DllCall method that works, but I don't know it offhand...

Hope this helps:

GuiCreate("Example Hotlink")

$link = GuiCtrlCreateLabel("Click me to go to AutoIt's homepage", 100, 100, 200, 20)
GuiCtrlSetFont($link, 9, 400, 4);underline
GuiCtrlSetColor($link, 0x0000FF)
;GuiCtrlSetCursor($link, 14);doesn't work?

GuiSetState()
While 1
   $msg = GuiGetMsg()
   If $msg = $link Then
      Run(@Comspec & ' /c start "" http://www.autoitscript.com', "",@SW_HIDE)
   ElseIf $msg = -3 Then
      Exit
   EndIf
WEnd
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI"); will create a dialog box that when displayed is centered

$a = GUICtrlCreateLabel("Hiddensoft forum", 10, 30, 100)  
$b = GUICtrlCreateLabel("Google", 10, 50, 100)  
$c = GUICtrlCreateLabel("Run! homepage", 10, 70, 100)
$d = GUICtrlCreateLabel("Shellcity", 10, 90, 100)

GUISetState()  

While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
   
   Select
      Case $msg = $a
         _ShellEx('http://www.hiddensoft.com/forum')
      Case $msg = $b
         _ShellEx('http://www.google.com')
      Case $msg = $c
         _ShellEx('http://crimsonfan.altervista.org')
      Case $msg = $d
         _ShellEx('http://www.shellcity.net')
   EndSelect
Wend

Func _ShellEx($sCmd)
   DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", '', "string", $sCmd, "string", '', "string", '', "long", @SW_SHOWNORMAL)
EndFunc  ;==>_ShellEx

Uff. you answerd when I was typing.

Edited by ezzetabi
Link to comment
Share on other sites

Here's a workaround:

GuiCreate("Example Hotlink Improved")

$link = GuiCtrlCreateLabel("Click me to go to AutoIt's homepage", 100, 100, 200, 20)
GuiCtrlSetColor($link, 0x0000FF)

Global $prev = -999
GuiSetState()
While 1
   $msg = GuiGetMsg()
   $info = GUIGetCursorInfo()
   If $prev <> $info[4] Then
      $prev = $info[4] ;prevent flicker (due to constantly calling GuiCtrlSetFont when unchanged)
      If $info[4] = $link Then;mouse over
         GuiSetCursor(0, 1)
         GuiCtrlSetFont($link, 9, 400, 4);underline
      Else
         GuiSetCursor(2, 1)
         GuiCtrlSetFont($link, 9, 400, 0);normal
      EndIf
   EndIf
   
   If $msg = $link Then
      Run(@Comspec & ' /c start "" http://www.autoitscript.com', "",@SW_HIDE)
   ElseIf $msg = -3 Then
      Exit
   EndIf
WEnd
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

CyberSlug, the cursor still does not change for me.

Thanks for everyone's help. However, I can not seem to get my code to work. Would someone please look at it and see where I am going wrong? I would really appreciate it. It probably has to do with the child vs. parent window, or something...

#include <GUIConstants.au3>    ; Must include for GUI functions to work

$parentgui = GUICreate ("Main", 280, 105) ; will create the main program window
$helpmenu = GUICtrlCreateMenu ("&Help")
$aboutitem = GUICtrlCreateMenuitem ("&About",$helpmenu)
GUISetState () ; will display the main program window

$link = 10000 ; must be declared first before using the Case

; Run the GUI until the dialog is closed
While 1
  $msg = GUIGetMsg (1)
  $ctrlmsg = $msg[0]
  $win = $msg[1]

  Select

    Case $ctrlmsg = $GUI_EVENT_CLOSE AND $win = $parentgui
      ExitLoop

    Case $ctrlmsg = $GUI_EVENT_CLOSE AND $win = $childgui
      GUISwitch ($parentgui)
      GUISetState (@SW_ENABLE)
      GUISwitch ($childgui)
      GUISetState (@SW_HIDE)

    Case $ctrlmsg = $aboutitem
      $winpos = WinGetPos ("Main")
      $childgui = GUICreate ("About", 260, 85, $winpos[0] + 10, $winpos[1] + 10, BitOr ($WS_POPUP, $WS_CAPTION, $WS_SYSMENU), -1, $parentgui)
      GUISetState (@SW_SHOW)
      GUICtrlCreateLabel ("Program Version 0.1.0" & chr(10) & chr(10) & "Copyright " & chr(169) & " 2004 Inc.", 62, 10, 150, 75, $SS_CENTER)
      $link = GUICtrlCreateLabel ("http://www.google.com", 62, 60, 150, 75, $SS_CENTER)
      GuiCtrlSetFont ($link, 9, 400, 4) ;underline
      GuiCtrlSetColor ($link, 0x0000FF) ;blue
;      GuiCtrlSetCursor ($link, 14) ;doesn't work?
      GUICtrlSetTip ($link, "Go Now!")
      GUISwitch ($parentgui)
      GUISetState (@SW_DISABLE)

    Case $ctrlmsg = $link AND $win = $childgui
      DllCall ("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", "", "string", "http://www.google.com/", "string", "", "string", "", "long", @SW_SHOWNORMAL)      


  EndSelect
Wend

GUIDelete ()

Exit

Twelve thank you's in advance :)

Edited by NewKreation
Link to comment
Share on other sites

Cool! I found a different way to get this to work using the mouse locator function.

#include <GUIConstants.au3>   ; Must include for GUI functions to work

$parentgui = GUICreate ("Main", 280, 105); will create the main program window
$helpmenu = GUICtrlCreateMenu ("&Help")
$aboutitem = GUICtrlCreateMenuitem ("&About",$helpmenu)
GUISetState (); will display the main program window

$link = 10000; must be declared first before using the Case

; Run the GUI until the dialog is closed
While 1
 $msg = GUIGetMsg (1)
 $ctrlmsg = $msg[0]
 $win = $msg[1]
 $winx = $msg[3]
 $winy = $msg[4]

 Select

   Case $ctrlmsg = $GUI_EVENT_CLOSE AND $win = $parentgui
     ExitLoop

   Case $ctrlmsg = $GUI_EVENT_CLOSE AND $win = $childgui
     GUISwitch ($parentgui)
     GUISetState (@SW_ENABLE)
     GUISwitch ($childgui)
     GUISetState (@SW_HIDE)

   Case $ctrlmsg = $aboutitem
     $winpos = WinGetPos ("Main")
     $childgui = GUICreate ("About", 260, 85, $winpos[0] + 10, $winpos[1] + 10, BitOr ($WS_POPUP, $WS_CAPTION, $WS_SYSMENU), -1, $parentgui)
     GUISetState (@SW_SHOW)
     GUICtrlCreateLabel ("Program Version 0.1.0" & chr(10) & chr(10) & "Copyright " & chr(169) & " 2004 Inc.", 62, 10, 150, 75, $SS_CENTER)
     $link = GUICtrlCreateLabel ("http://www.google.com", 62, 60, 150, 75, $SS_CENTER)
     GuiCtrlSetFont ($link, 9, 400, 4);underline
     GuiCtrlSetColor ($link, 0x0000FF);blue
;      GuiCtrlSetCursor ($link, 14);doesn't work?
     GUICtrlSetTip ($link, "Go Now!")
     GUISwitch ($parentgui)
     GUISetState (@SW_DISABLE)

   Case $winx > 62 AND $winx < 212 AND $winy > 60 AND $winy < 135 AND $ctrlmsg = $GUI_EVENT_PRIMARYUP AND $win = $childgui
     DllCall ("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", "", "string", "http://www.google.com/", "string", "", "string", "", "long", @SW_SHOWNORMAL)      


 EndSelect
Wend

GUIDelete ()

Exit
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...