Mouseover Links in AutoHotkey

What's this all about? Well I want the basic hover effect: when my mouse cursor hovers over a link, I want that link to turn blue and display an underline. When I move the cursor away from the link, I want the link returned to black without an underline.

How?
copyraw
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force

; ******************************************************************************
; CREATE GUI

Gui, Color, FFFFFF
Gui, +OwnDialogs +SysMenu +Caption +0x800000
Gui, Add, Text, gOpenDocumentation, Open the documentation
Gui, Show, w600 h700, %ThisProgramName%
WinSet, AlwaysOnTop, On, %ThisProgramName%
OnMessage(0x200, "WM_MOUSEMOVE")
Return

OpenDocumentation:
   MsgBox, Oh no you clicked on me!
Return

; ******************************************************************************
; MOUSE MOVEMENT (Tooltips)

WM_MOUSEMOVE()
{
    static CurrControl, PrevControl
    CurrControl := A_GuiControl

	If (CurrControl"" OR PrevControl"") {
		If (CurrControl  PrevControl)
		{
			Gui, Font, cBlue underline
			GuiControl, Font, %CurrControl%
			PrevControl:=CurrControl
		} else {
			Gui, Font, cBlack norm
			GuiControl, Font, %CurrControl%
			PrevControl:=""
		}
	}
}

; ******************************************************************************

	GuiClose:
	close:
		Gui, Destroy
		ExitApp
  1.  #NoEnv 
  2.  SendMode Input 
  3.  SetWorkingDir %A_ScriptDir% 
  4.  #SingleInstance Force 
  5.   
  6.  ; ****************************************************************************** 
  7.  ; CREATE GUI 
  8.   
  9.  Gui, Color, FFFFFF 
  10.  Gui, +OwnDialogs +SysMenu +Caption +0x800000 
  11.  Gui, Add, Text, gOpenDocumentation, Open the documentation 
  12.  Gui, Show, w600 h700, %ThisProgramName% 
  13.  WinSet, AlwaysOnTop, On, %ThisProgramName% 
  14.  OnMessage(0x200, "WM_MOUSEMOVE") 
  15.  Return 
  16.   
  17.  OpenDocumentation: 
  18.     MsgBox, Oh no you clicked on me! 
  19.  Return 
  20.   
  21.  ; ****************************************************************************** 
  22.  ; MOUSE MOVEMENT (Tooltips) 
  23.   
  24.  WM_MOUSEMOVE() 
  25.  { 
  26.      static CurrControl, PrevControl 
  27.      CurrControl := A_GuiControl 
  28.   
  29.      If (CurrControl"" OR PrevControl"") { 
  30.          If (CurrControl  PrevControl) 
  31.          { 
  32.              Gui, Font, cBlue underline 
  33.              GuiControl, Font, %CurrControl% 
  34.              PrevControl:=CurrControl 
  35.          } else { 
  36.              Gui, Font, cBlack norm 
  37.              GuiControl, Font, %CurrControl% 
  38.              PrevControl:="" 
  39.          } 
  40.      } 
  41.  } 
  42.   
  43.  ; ****************************************************************************** 
  44.   
  45.      GuiClose: 
  46.      close: 
  47.          Gui, Destroy 
  48.          ExitApp 
Now this results in a tiny GUI that displays the link in black and works (somewhat). If you copy the above code into an AutoHotkey file, you'll find this is remarkably temperamental. If the user is too quick with their mouseovers and mouseouts, then the GUI will sometimes leave the link as blue despite the mouse cursor not being anywhere near it.

Proper HTML mouseovers:
When I have a more stable solution. I would however recommend cwebpage.dll at as a minimum for internal HTML pages for use in an AutoHotkey GUI.
Category: AutoHotkey :: Article: 369

Add comment

Your rating:

Submit

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Please publish modules in offcanvas position.