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

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

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
© 2024 Joel Lipman .com. All Rights Reserved.