MrCreatoR Posted March 26, 2011 Share Posted March 26, 2011 (edited) AutoIt version: 3.3.6.1UDF version: 1.2Description: This library allows easily to create HyperLink controls.Few Label-distinctive features: * Opening of the hyperlink/function (see bellow) is performed only after the mouse button is released, and only when the element is hovering. * Changing of the color for visited (open) link. * When dragging the hyperlink, mouse cursor is changed to NOT ALLOWED (indicating that link can not be dragged). * There is ability not just to open links, but also call user function. Example: #include <GUIConstantsEx.au3> #include "GUIHyperLink.au3" $hGUI = GUICreate("GUICtrlHyperLink UDF Demo!", 300, 200) $nAutoItScript_Com_HyperLink = _GUICtrlHyperLink_Create("AutoIt Official Website", 100, 50, 110, 15, 0x0000FF, 0x551A8B, _ -1, 'http://google.com', 'Visit: www.google.com', $hGUI) ;Intentionally set as google.com, will change later $nAutoItScript_Ru_HyperLink = _GUICtrlHyperLink_Create("AutoIt Russian Community", 90, 80, 130, 15, 0x0000FF, 0x551A8B, _ -1, 'http://autoit-script.ru', 'Visit: www.autoit-script.ru', $hGUI) $nCreatoRLab_HyperLink = _GUICtrlHyperLink_Create("CreatoR's Lab", 120, 110, 70, 15, 0x0000FF, 0x551A8B, _ 1, '_CreatoRLab_ShowInfo(@THIS@, ' & $hGUI & ')', 'Show website information...', $hGUI) _GUICtrlHyperLink_SetData($nAutoItScript_Com_HyperLink, 2, 'www.autoitscript.com') GUICtrlSetTip($nAutoItScript_Com_HyperLink, 'Visit: www.autoitscript.com') GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _CreatoRLab_ShowInfo($nCtrlID, $h_GUI) MsgBox(64, 'Info', 'HyperLink Clicked:' & @CRLF & GUICtrlRead($nCtrlID), 0, $h_GUI) EndFunc Attachments:GUIHyperLink_1.2.zipGUICtrlHyperLink_1.1.zipGUICtrlHyperLink_1.0.zipScreenshot:Changelog:v1.2 * Attempt to fix the issue when sometimes script crashed with error: "Array variable has incorrect number of subscripts or subscript dimension range exceeded".v1.1 + Added _GUICtrlHyperLink_SetData function. Sets HyperLink control data. * Changed example. * Fixed "THIS" issue, now use @THIS@ instead. * Fixed issue with receiving clicks even if the HyperLink label is under other window (the main window not active). * Fixed issue with receiving clicks when the mouse "down click" was made not on the label control.v1.0 First public version. Edited May 13, 2013 by MrCreatoR yahaosoft and jparnell8839 2 Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
ivan Posted March 26, 2011 Share Posted March 26, 2011 Thanks for sharing. I used to create rich edit controls with a hyperlink to then trace the click event via registered messages. This is much neater. Regards, Ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
Andreik Posted March 27, 2011 Share Posted March 27, 2011 Nice and smart way to create a hyperlink control. Good work. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
MrCreatoR Posted June 16, 2011 Author Share Posted June 16, 2011 Update!v1.1+ Added _GUICtrlHyperLink_SetData function. Sets HyperLink control data.* Changed example.* Fixed "THIS" issue, now use @THIS@ instead.* Fixed issue with recieving clicks even if the HyperLink label is under other window (the main window not active).* Fixed issue with recieving clicks when the mouse "down click" was made not on the label control.Please check the first post. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
souldjer777 Posted November 27, 2012 Share Posted November 27, 2012 (edited) Has anyone ever placed a combo box above their hyperlinks in a single gui and had both selected at the same time w/ one click? I have a drop down list combo box directly above my hyperlinks and when I click anything from the combo box located above my hyperlinks - both are selected at the same time. BTW - My drop down list combo box populates on top of my hyperlinks... so that's the main issue I know... I'm just hoping their is an easy fix or workaround. - If this post shouldn't be here I apologize - Please delete it - I can always ask elsewhere. Thanks! Example here: Edited November 27, 2012 by souldjer777 "Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"Song Title: I guess you could sayArtist: Middle Class Rut Link to comment Share on other sites More sharing options...
MrCreatoR Posted May 13, 2013 Author Share Posted May 13, 2013 Update! v1.2 * Attempt to fix the issue when sometimes script crashed with error: "Array variable has incorrect number of subscripts or subscript dimension range exceeded". Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
kamiquasi Posted September 25, 2013 Share Posted September 25, 2013 (edited) Hi, I checked out your Hyperlink control after I got stuck with my own - only to find that you're doing much the same I had done, and have the same limitation: There's no keyboard interaction. When I initially added WS_TABSTOP, I realized there was no focus indication, and things just got progressively more insane from there. Here's a mock-up of what I ended up doing (lots of duplicate code, nothing even half-way automated): expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hwndWindow = GUICreate("Dialog", 300, 120); Simplified hyperlink label $idLabelFocus = GUICtrlCreateLabel("Control with focus: ", 8, 8, 280, 17) $idLabelActivity = GUICtrlCreateLabel("Activity: ", 8, 24, 208, 17) $idHyperlinkG = GUICtrlCreateLabel("www.google.com", 8, 48, 200, 17, $WS_TABSTOP) $idHyperlinkA = GUICtrlCreateLabel("www.autoitscript.com", 8, 64, 200, 17, $WS_TABSTOP) $idButton1 = GUICtrlCreateButton("Button 1", 8, 80, 100, 17, $WS_TABSTOP) $idButton2 = GUICtrlCreateButton("Button 2", 108, 80, 100, 17, $WS_TABSTOP) ; Change the labels to appear like hyperlinks GUICtrlSetColor($idHyperlinkG,0x0000ff) GUICtrlSetColor($idHyperlinkA,0x0000ff) GUICtrlSetCursor($idHyperlinkG,0) GUICtrlSetCursor($idHyperlinkA,0) ; Get the hyperlinks' HWNDs Global $hwndHyperlinkG = GuiCtrlGetHandle($idHyperlinkG) Global $hwndHyperlinkA = GuiCtrlGetHandle($idHyperlinkA) ; Initialize the focus to the first control (first tabstop?) Global $hwndFocused $hwndFocused = $hwndHyperlinkG ; Set the font once here.Setting the font later slightly changes the kerning ('www' widens) so pre-widen it. GUICtrlSetFont($idHyperlinkG,-1,-1,4) ; First tabstop'd control, has focus already, underline it GUICtrlSetFont($idHyperlinkA,-1,-1,1) ; Set up a hotkey for the TAB key (duplicate all relevant for shift-tab) HotKeySet("{TAB}","tab") Func tab() ControlSetText($hwndWindow,"",$idLabelActivity,"{TAB} pressed") ; Act as if this wasn't a HotKey by re-sending it with the HotKey off HotKeySet("{TAB}") Send("{TAB}") HotKeySet("{TAB}","tab") ; Get the control that has focus and cache it local $nnFocused = ControlGetFocus($hwndWindow) $hwndFocused = ControlGetHandle($hwndWindow,"",$nnFocused) ControlSetText($hwndWindow,"",$idLabelFocus,"Control with focus: " & $nnFocused & " (" & $hwndFocused & ")") ; Set up a HotKey on {ENTER} if focus is on a hyperlink, otherwise remove it Switch $hwndFocused Case $hwndHyperlinkG GUICtrlSetFont($idHyperlinkA,-1,-1,1) GUICtrlSetFont($idHyperlinkG,-1,-1,4) HotKeySet("{ENTER}","enter") Case $hwndHyperlinkA GUICtrlSetFont($idHyperlinkG,-1,-1,1) GUICtrlSetFont($idHyperlinkA,-1,-1,4) HotKeySet("{ENTER}","enter") Case Else GUICtrlSetFont($idHyperlinkA,-1,-1,1) GUICtrlSetFont($idHyperlinkG,-1,-1,1) HotKeySet("{ENTER}") EndSwitch EndFunc ; Open hyperlinks depending on the control that last had focus. Func enter() ControlSetText($hwndWindow,"",$idLabelActivity,"{ENTER} pressed") Switch $hwndFocused Case $hwndHyperlinkG ControlSetText($hwndWindow,"",$idLabelActivity,"Google link {ENTER}'d") ; ShellExecute("https://www.google.com/") Case $hwndHyperlinkA ControlSetText($hwndWindow,"",$idLabelActivity,"AutoIt link {ENTER}'d") ; ShellExecute("http://www.autoitscript.com/") EndSwitch EndFunc ; Window activation handling. Disable the TAB and ENTER hotkeys if own window is not the active window, ; re-register ENTER only if hyperlink was in focus last GUIRegisterMsg($WM_ACTIVATE,"WM_ACTIVATE") Func WM_ACTIVATE($hWnd,$Msg,$wParam,$lParam) If ($hWnd == $hwndWindow) Then local $nnFocused = ControlGetFocus($hwndWindow) If ($nnFocused == "") Then $nnFocused = $hwndFocused & " (cached hwnd)" EndIf ControlSetText($hwndWindow,"",$idLabelFocus,"Control with focus: " & $nnFocused) If ($wParam) Then ControlSetText($hwndWindow,"",$idLabelActivity,"Window activated") HotKeySet("{TAB}","tab") Switch $hwndFocused Case $hwndHyperlinkG, $hwndHyperlinkA HotKeySet("{ENTER}","enter") Case Else HotKeySet("{ENTER}") EndSwitch Else ControlSetText($hwndWindow,"",$idLabelActivity,"Window deactivated") HotKeySet("{TAB}") HotKeySet("{ENTER}") EndIf EndIf EndFunc ; Show the GUI GUISetState(@SW_SHOW) ; Standard handlers (e.g. clicking on the label/static control) ; Set underline as appropriate, force focus to control (click on static doesn't set focus) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idHyperlinkG ControlSetText($hwndWindow,"",$idLabelActivity,"Google link clicked") GUICtrlSetFont($idHyperlinkA,-1,-1,1) GUICtrlSetFont($idHyperlinkG,-1,-1,4) _WinAPI_SetFocus($hwndHyperlinkG) ; ShellExecute("https://www.google.com/") Case $idHyperlinkA ControlSetText($hwndWindow,"",$idLabelActivity,"AutoIt link clicked") GUICtrlSetFont($idHyperlinkA,-1,-1,4) GUICtrlSetFont($idHyperlinkG,-1,-1,1) _WinAPI_SetFocus($hwndHyperlinkA) ; ShellExecute("http://www.autoitscript.com/") Case $idButton1 ControlSetText($hwndWindow,"",$idLabelActivity,"Button 1 mashed") GUICtrlSetFont($idHyperlinkA,-1,-1,1) GUICtrlSetFont($idHyperlinkG,-1,-1,1) Case $idButton2 ControlSetText($hwndWindow,"",$idLabelActivity,"Button 2 mashed") GUICtrlSetFont($idHyperlinkA,-1,-1,1) GUICtrlSetFont($idHyperlinkG,-1,-1,1) EndSwitch WEnd Perhaps a better solution could be incorporated into GUIHyperLink P.S. IDC_HAND didn't show a hand cursor for me either. Is this a known bug, or...? Edited September 25, 2013 by kamiquasi Link to comment Share on other sites More sharing options...
13lack13lade Posted October 10, 2013 Share Posted October 10, 2013 Works perfectly for me, thank you! Link to comment Share on other sites More sharing options...
GOGOKOM Posted August 14, 2014 Share Posted August 14, 2014 How do close the window after a specified time.I tried to sleep and exit - and nothing Link to comment Share on other sites More sharing options...
Trolleule Posted November 6, 2014 Share Posted November 6, 2014 don't works with child GUI's and or tabs 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