Jump to content

GuiSysLink UDF


Yashied
 Share

Recommended Posts

LAST VERSION - 1.0

09-May-11

I don't know why AutoIt does not support SysLink controls, and I tried to fix it. This library is written similary as other AutoIt GUI libraries. For more information, see detailed descriptions of all functions inside GuiSysLink.au3.

SysLink.png

Available functions

_GUICtrlSysLink_Create

_GUICtrlSysLink_Destroy

_GUICtrlSysLink_GetIdealHeight

_GUICtrlSysLink_GetIdealSize

_GUICtrlSysLink_GetItemEnabled

_GUICtrlSysLink_GetItemFocused

_GUICtrlSysLink_GetItemHighlighted

_GUICtrlSysLink_GetItemID

_GUICtrlSysLink_GetItemState

_GUICtrlSysLink_GetItemUrl

_GUICtrlSysLink_GetItemVisited

_GUICtrlSysLink_GetText

_GUICtrlSysLink_HitTest

_GUICtrlSysLink_HitTestEx

_GUICtrlSysLink_SetItemEnabled

_GUICtrlSysLink_SetItemFocused

_GUICtrlSysLink_SetItemHighlighted

_GUICtrlSysLink_SetItemID

_GUICtrlSysLink_SetItemState

_GUICtrlSysLink_SetItemUrl

_GUICtrlSysLink_SetItemVisited

_GUICtrlSysLink_SetText

SysLink UDF Library v1.0

Previous downloads: 161

SysLink.zip

Example

#include <GUIConstantsEx.au3>
#include <GUISysLink.au3>
#include <GUIStatusBar.au3>
#include <WindowsConstants.au3>

$Text = 'The SysLink controls provides a convenient way to embed hypertext links in a window. For more information, click <A HREF="http://msdn.microsoft.com/en-us/library/bb760706(VS.85).aspx">here</A>.' & @CRLF & @CRLF & _
        'To learn how to use the SysLink controls in AutoIt, click <A HREF="http://www.autoitscript.com/forum/">here</A>.'

$hForm = GUICreate("MyGUI", 428, 160)
$hStatusBar = _GUICtrlStatusBar_Create($hForm)
$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 10, 10, 408, 54)
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

While 1
    _SysLink_Over()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy
            ShellExecute(_GUICtrlSysLink_GetItemUrl($hSysLink, GUICtrlRead($Dummy)))
    EndSwitch
WEnd

Func _SysLink_Over()

    Local $Link = _GUICtrlSysLink_HitTest($hSysLink)

    For $i = 0 To 1
        If $i = $Link Then
            If Not _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 1)
                _GUICtrlStatusBar_SetText($hStatusBar, _GUICtrlSysLink_GetItemUrl($hSysLink, $i))
            EndIf
        Else
            If _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 0)
                _GUICtrlStatusBar_SetText($hStatusBar, "")
            EndIf
        EndIf
    Next
EndFunc   ;==>_SysLink_Over

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
    Local $hFrom = DllStructGetData($tNMLINK, "hWndFrom")
    Local $ID = DllStructGetData($tNMLINK, "Code")

    Switch $hFrom
        Case $hSysLink
            Switch $ID
                Case $NM_CLICK, $NM_RETURN
                    GUICtrlSendToDummy($Dummy, DllStructGetData($tNMLINK, "Link"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by Yashied
Link to comment
Share on other sites

Thanks for sharing.

MrCreator posted yesterday but I must point that SysLink is a more appropriate name selection for the control than gui hyperlink. In any case, this is much better than how I used to track links on rich edit controls to simulate the SysLink control.

Great work to all (Gary, MrCreator and Yashied). The one thing I'm going to miss from simulating SysLinks via Rich edit controls is being able to apply style to text.

Regards,

IVAN

Link to comment
Share on other sites

@ivan: There is a small difference between this UDF and the one from MrCreator.

SysLink is a native control, that displays text like a label and parses links. GUICtrlHyperLink is just a label with predefined functionality :)

RichEidt should also allow links, but it is not too easy to create them.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Thx ProgAndy. I knew SysLinks controls were native, and found them difficult to handle in automation. Your script not only provides a means to create these controls but may also address Autoit's main purpose, automation, which gives it an additional advantage, not to dismiss the merit of any other alternatives.

Taking a closer look at MrCreator's script you are quite right, it's a label with a predefined behavior. As for the rich edit alternative, I never wrote a fully fledged UDF simultation of a SysLink, because my script(s) were basically a sub part (the About) of other scripts, and I never got round to making something of general applicability that may be re-utilized. Every other About I created, I just copied entire sections of old scripts and pasted them in new scripts, edited as required ... not very efficient, shame on me, I know.

Anyhow, ThumbsUp for this effort.

Ivan

Edited by ivan
Link to comment
Share on other sites

Nice UDF but I have a question, why is the example listening for $NM_RETURN?

Ok so you can tab them after one being pressed...

Edit1: Also noted that if you press the AutoIt link in the example MSDN opens when on x64. What a mess.

Edit2: DllStructGetData($tNMLINK, "Link") always returns 0 on x64.

Edit3: How do you get the background color right? (like on tabs)

Edited by AdmiralAlkex
Link to comment
Share on other sites

  • 1 month later...

DllStructGetData($tNMLINK, "Link") always returns 0 on x64.

#1479

Replace

$tagNMLINK = $tagNMHDR & ";" & $tagLITEM

to

$tagNMLINK = "hwnd hWndFrom;uint_ptr IDFrom;int_ptr Code;" & $tagLITEM

in SysLinkConstants.au3.

Link to comment
Share on other sites

Any idea about the background color?

#include <GUIConstantsEx.au3>
#include <GUISysLink.au3>
#include <GUIStatusBar.au3>
#include <WindowsConstants.au3>

$Text = 'The SysLink controls provides a convenient way to embed hypertext links in a window. For more information, click <A HREF="http://msdn.microsoft.com/en-us/library/bb760706(VS.85).aspx">here</A>.' & @CRLF & @CRLF & _
        'To learn how to use the SysLink controls in AutoIt, click <A HREF="http://www.autoitscript.com/forum/">here</A>.'

$hForm = GUICreate("MyGUI", 468, 180)
$hStatusBar = _GUICtrlStatusBar_Create($hForm)
GUICtrlCreateTab(10, 10, 450, 138)
GUICtrlCreateTabItem('Tab1')
$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 30, 44, 408, 54)
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_CTLCOLORSTATIC, "WM_CTLCOLORSTATIC")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

While 1
    _SysLink_Over()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy
            ShellExecute(_GUICtrlSysLink_GetItemUrl($hSysLink, GUICtrlRead($Dummy)))
    EndSwitch
WEnd

Func _SysLink_Over()

    Local $Link = _GUICtrlSysLink_HitTest($hSysLink)

    For $i = 0 To 1
        If $i = $Link Then
            If Not _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 1)
                _GUICtrlStatusBar_SetText($hStatusBar, _GUICtrlSysLink_GetItemUrl($hSysLink, $i))
            EndIf
        Else
            If _GUICtrlSysLink_GetItemHighlighted($hSysLink, $i) Then
                _GUICtrlSysLink_SetItemHighlighted($hSysLink, $i, 0)
                _GUICtrlStatusBar_SetText($hStatusBar, "")
            EndIf
        EndIf
    Next
EndFunc   ;==>_SysLink_Over

Func WM_CTLCOLORSTATIC($hWnd, $iMsg, $wParam, $lParam)
    Switch $lParam
        Case $hSysLink
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_CTLCOLORSTATIC

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMLINK = DllStructCreate($tagNMLINK, $lParam)
    Local $hFrom = DllStructGetData($tNMLINK, "hWndFrom")
    Local $ID = DllStructGetData($tNMLINK, "Code")

    Switch $hFrom
        Case $hSysLink
            Switch $ID
                Case $NM_CLICK, $NM_RETURN
                    GUICtrlSendToDummy($Dummy, DllStructGetData($tNMLINK, "Link"))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

If you add the style $WS_TABSTOP to the control, the links are added to the normal tab-navigation of the GUI, so just press tab to select the link you want to open and press enter :unsure:

$hSysLink = _GUICtrlSysLink_Create($hForm, $Text, 30, 44, 408, 54, $WS_TABSTOP)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 2 years later...
Link to comment
Share on other sites

  • 8 months later...

Very usefull UDF 

I notice it works on AutoIt 3.3.10.2 but not on AutoIt 3.3.13.8

It is because __UDF_ValidateClassName() was removed from UDFGlobalID.au3

but Why it is removed with out any notice ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

It is because __UDF_ValidateClassName() was removed from UDFGlobalID.au3

but Why it is removed with out any notice ?

Because it's an internal function. It was also a pointless function that served no real purpose.

Anything that is documented and breaks will be mentioned in the appropriate section.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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...