Jump to content
Sign in to follow this  
Tagor

Create a link and run something

Recommended Posts

Tagor

Hi,

I have searched in the manual, but I couldn't find this:

I would like to create a link and onces it is clicked, it should run a certain code. Is this possible with autoit?

Thanks! :)

Share this post


Link to post
Share on other sites
MHz

Like a hyperlink? Would not a button be better? :)

Share this post


Link to post
Share on other sites
Somerset

FileCreateShortcut ?


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites
sylvanie

hello,

is it what do you need ?

#include <GUIConstants.au3>



GuiCreate("MyGUI", 390, 316,(@DesktopWidth-390)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label_1 = GuiCtrlCreateLabel("click me to run", 50, 80, 190, 20)
GUICtrlSetColor ( -1, 0x0000ff)
GUICtrlSetFont (-1, -1 , 800 , 6 )
GUICtrlSetCursor ( -1, 0 )
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg= $Label_1
        run("your_exe.exe")
    Case Else
    ;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites
Tagor

Thank, that is what I was searching for. Is there also a way to include this is an already existing label?

Share this post


Link to post
Share on other sites
zcoacoaz

type this part of the code below the label

GUICtrlSetColor ( -1, 0x0000ff)
GUICtrlSetFont (-1, -1 , 800 , 6 )
GUICtrlSetCursor ( -1, 0 )

then add an action to the message loop


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites
Tagor

I am not sure. But doesn't the above code change the color and font of the text? I would like to have something like this:

text text text HYPERLINK text text text text text.

Share this post


Link to post
Share on other sites
layer

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Link..", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

GuiCtrlCreateLabel("NOT A LINK", 30, 110, 60, 20)
$link = GuiCtrlCreateLabel("LINK", 100, 110, 30, 20)
GuiCtrlCreateLabel("NOTALINK", 140, 110, 60, 20)
GUICtrlSetColor($link, 0x0000FF)
GUICtrlSetCursor($link, 0)
GUICtrlSetTip($link, "A msgbox")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit


FootbaG

Share this post


Link to post
Share on other sites
GaryFrost

Example below for e-mail, can be any kind of hyperlink.

#include <GUIConstants.au3>
#include <Inet.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Link..", 392, 316,(@DesktopWidth-392)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

   $LABEL = _GuiCtrlCreateHyperlink("Email me", 27, 130, 443, 20, 0x0000ff, 'E-Mail ' & "yourmail.com" & " (comments/questions)")
   $CLOSE = GUICtrlCreateButton("Close", 200, 190, 85, 20)
   GUISetState()
   Do
      $MSG = GUIGetMsg()
      Select
         Case $MSG = $CLOSE
            ExitLoop
         Case $MSG = $LABEL
            _INetMail($MAILTO, "Regarding " & $TITLE, "")
      EndSelect
   Until $MSG = $GUI_EVENT_CLOSE

;===============================================================================
;
; Function Name:    _GuiCtrlCreateHyperlink()
; Description:      Creates a label that acts as a hyperlink
;                   
; Parameter(s):     $s_Text       - Label text
;                   $i_Left          - Label left coord
;                   [$i_Top]      - Label top coord
;                    [$i_Width]      - Label width
;                   [$i_Height]      - Label height
;                    [$i_Color]      - Text Color
;                    [$s_ToolTip]  - Hyperlink ToolTip
;                    [$i_Style]      - Label style
;                    [$i_ExStyle]  - Label extended style
;
; Requirement(s):   None
; Return Value(s):  Control ID
;                   
; Author(s):        Saunders <krawlie@hotmail.com>
;
;===============================================================================

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)
    Local $i_CtrlID
    $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, -1, 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
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.