Sign in to follow this  
Followers 0
themax90

Creating Links in a Label?

14 posts in this topic

How do I create a link in a label so that it looks like a link on the web.

Blue, underlined and if you click on it then he will goto a site with the default web client.

Link in Label

Can you help?

Share this post


Link to post
Share on other sites



Figured it out, sorry for the post.

Func OpenSite($SitePath)
    If @OSTYPE = 'WIN32_NT' Then
        $Str = @ComSpec & ' /c start "" '
    Else
        $Str = @ComSpec & ' /c start '
    EndIf
    SplashTextOn( "Opening", "Website " & $SitePath & " opening.", 400, 25)
    Run($Str & $SitePath, '', @SW_HIDE)
    Sleep(1500)
    SplashOff()
EndFunc  ;==>OpenSite

Share this post


Link to post
Share on other sites

thanks ive been wanting to do that :lmao:


FootbaG

Share this post


Link to post
Share on other sites

No problem man, I actually picked it apart from the AutoIt Updater :lmao:

Share this post


Link to post
Share on other sites

ohh yea, i was looking for it in there too! when it first came out, but i was too lazy to go threw all that code :lmao:


FootbaG

Share this post


Link to post
Share on other sites

I just used SciTe to Mark All http://'s and found _Start("http:.....") function.

I marked the _Start function and figured it out, :lmao:!!!

Have fun!

Share this post


Link to post
Share on other sites

Woot, glad to see people are getting some use out of my script. :lmao:

Share this post


Link to post
Share on other sites

Yah, thanks Saunders, can you figure out my Checkbox issuethough?

Share this post


Link to post
Share on other sites

but how do you make the link...? i guess u could use GUICtrlSetMouse or w/e it is Cursor... and make it blue and underlined... ? and GUICtrlSetTip but is there an easier way to make a link... i guess just to put it all in one function.. whatvere, im just thinking, dont mind me :lmao:


FootbaG

Share this post


Link to post
Share on other sites

Heres an example they could maybe put in the help file:

#include <GuiConstants.au3>
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
$gui = GUICreate("Example", 197, 109, (@DesktopWidth - 197) / 2, (@DesktopHeight - 109) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Label_1 = GUICtrlCreateLabel("Clicking on the below text will open a website, hovering over it will create a tip.", 10, 10, 180, 50)
$Label_2 = GUICtrlCreateLabel("Visit Google.", 10, 80, 180, 20)
GUICtrlSetColor($Label_2, 0x0000ff)
GUICtrlSetFont($Label_2, 9, 400, 4)
GUICtrlSetTip($Label_2, "http://www.google.com/")
GUISetState()
While 1
    $msg = GUIGetMsg(1)
    $msg_event = $msg[0]
    $msg_win = $msg[1]
    If $msg_event = $GUI_EVENT_CLOSE And $msg_win = $gui Then
        Exit
    EndIf
    If $msg_event = $Label_2 And $msg_win = $gui Then
        OpenSite("http://www.google.com")
    EndIf
Wend
Exit
Func OpenSite($SitePath)
    If @OSTYPE = 'WIN32_NT' Then
        $Str = @ComSpec & ' /c start "" '
    Else
        $Str = @ComSpec & ' /c start '
    EndIf
    SplashTextOn( "Opening", "Website " & $SitePath & " opening.", 400, 25)
    Run($Str & $SitePath, '', @SW_HIDE)
    Sleep(1500)
    SplashOff()
EndFunc  ;==>OpenSite

Have fun!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I tried.

*Edit: This was responding to Smith's request to help with checkboxes... I didn't refresh the page before posting. :lmao:

Edited by Saunders

Share this post


Link to post
Share on other sites

but how do you make the link...? i guess u could use GUICtrlSetMouse or w/e it is Cursor... and make it blue and underlined... ? and GUICtrlSetTip but is there an easier way to make a link... i guess just to put it all in one function.. whatvere, im just thinking, dont mind me :lmao:

<{POST_SNAPBACK}>

A function eh?

Hmm... would a UDF do?

Func _GuiCtrlCreateHyperlink($s_Text, $i_Left, $i_Top, $i_Width = -1, $i_Height = -1, $i_Color = 0x0000ff, $s_ToolTip = '', $i_Style = -1, $i_ExStyle = -1)
    $i_CtrlID = GuiCtrlCreateLabel($s_Text, $i_Left, $i_Top, $i_Width, $i_Height, $i_Style, $i_ExStyle)
    If $i_CtrlID <> 0 Then
        GuiCtrlSetFont($i_CtrlID, -1, 400, 4)
        GuiCtrlSetColor($i_CtrlID, $i_Color)
        GuiCtrlSetCursor($i_CtrlID, 0)
        If $s_ToolTip <> '' Then
            GuiCtrlSetTip($i_CtrlID, $s_ToolTip)
        EndIf
    EndIf
    
    Return $i_CtrlID
EndFunc

Working Example:

#include <GUIConstants.au3>

$gui_Main = GUICreate("Hyperlink Test", 350, 212)

$hl_AutoIt = _GuiCtrlCreateHyperlink('Visit AutoIt Homepage!', 5, 5, 200, 20, 0x0000ff, 'AutoItScript.com')
$hl_Layer = _GuiCtrlCreateHyperlink('Visit Layer''s Homepage!', 5, 30, 200, 20, 0xff0000, 'Geocities.com/grxskate/', $SS_SUNKEN)

GuiSetState()

Do
    $msg = GuiGetMsg()
    
    If $msg = $hl_AutoIt Then
        MsgBox(8192,0,'http://www.autoitscript.com/')
    ElseIf $msg = $hl_Layer Then
        MsgBox(8192,0,'http://www.geocities.com/grxskate/')
    EndIf
    
Until $msg = $GUI_EVENT_CLOSE

Personally, I'd never use it, but I guess it would seem simpler for some people.

Share this post


Link to post
Share on other sites

Wow thats so much more complicated then my way. You are such an amazing complicated person!!! Lol

J/k!

Share this post


Link to post
Share on other sites

Wow thats so much more complicated then my way. You are such an amazing complicated person!!! Lol

J/k!

<{POST_SNAPBACK}>

Heh, like I said, I'd never use the function, I'd do all the GuiCtrlSet... stuff myself. But for people who just want a quick fix, they could include that function and make a "hyperlink" as quickly/easily as a label.

Share this post


Link to post
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
Sign in to follow this  
Followers 0