Jump to content

Recommended Posts

Posted

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?

Posted

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
Posted

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
Posted

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!

Posted

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
Posted

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!

Posted

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.

Posted

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.

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
  • Recently Browsing   0 members

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