Jump to content

Recommended Posts

Posted (edited)

AutoIt version: 3.3.6.1
UDF version: 1.2

Description: This library allows easily to create HyperLink controls.
Few Label-distinctive features:


  Quote

* 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:

  Reveal hidden contents



Attachments:
GUIHyperLink_1.2.zip
GUICtrlHyperLink_1.1.zip
GUICtrlHyperLink_1.0.zip


Screenshot:
GUICtrlHyperLink_UDF.png

Changelog:

  Reveal hidden contents
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 by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 2 months later...
Posted

Update!

  Quote

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.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 1 year later...
Posted (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 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 say
Artist: Middle Class Rut

  • 5 months later...
Posted

Update!

  Quote

 

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

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 4 months later...
Posted (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):

#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 by kamiquasi
  • 3 weeks later...
  • 10 months later...
  • 2 months later...

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