Or this. Same thing but with added WM_MOUSEMOVE stuff. Crude, I know, but it demonstrates the point: LeftClick remap will not interfere with MouseMove.
Code:
;ORIGINAL CODE BY Tasman HERE: http://www.autohotkey.com/forum/viewtopic.php?t=12334
#persistent
leftclick("off") ;by default disable the leftclick remap
Menu, Tray, Icon, pifmgr.dll, 2 ; set the icon for this script
; the icon to look for (in this case the one of this script)
iconstr = 2 pifmgr.dll ; the number of the icon [space] filename containing the icon
; get the icon sizes (system small) in order to determine the size of the area for the mouseover event
sysget, sm_cxsmicon, 49
sysget, sm_cysmicon, 50
virtualkey = VK07
debounce=0
; MsgBox, %sm_cxsmicon% %sm_cysmicon%
OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x2A3, "WM_MOUSELEAVE")
SetTimer, mouseovericon, 250 ; check if the mouse is over the icon
SetTimer, CheckForClick, 25
DetectHiddenWindows, On
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Gui, Add, Button,, Keyboard
Gui, +LastFound +AlwaysOnTop
guiID := WinExist()
Return
guiClose:
ExitApp
Return
mouseovericon:
mouseovericon := iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
if mouseovericon = 0
{ leftclick("on")
}
Else
{ leftclick("off")
If GetKeyState(%virtualkey%)
{ Send, {%virtualkey% Up} ;make sure it's up
debounce=0
}
}
Return
iconfind(iconstr,sm_cxsmicon,sm_cysmicon)
; checks to see if the mouse is over the given tray icon
; returns:
; 0 if mouse is over the icon,
; 1 if image not found
; 2 if imagesearch produced an error or
; 3 if icon was found but mouse was not over the image
{
coordmode, pixel, screen ; set the coords for imagesearch to absolute
coordmode, mouse, screen ; set mouse coords to absolute
; retrieve the tray position and size in order to limit (speedup) the imagesearch
WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd
MouseGetPos, mouseX, mouseY ; get the mouse position
; see if the icon exists in the traywindow
ImageSearch, imageX, imageY, trayX, trayY, trayX+trayWidth, trayY+trayHeight, *Icon%iconstr%
coordmode, pixel, relative ; reset the coords for imagesearch to default
coordmode, mouse, relative ; reset mouse coords to default
if ErrorLevel > 0 ; image not found or an image search error occurred
return %errorlevel%
imageXlarge := imageX+sm_cxsmicon ; the outerlimit for X
imageYlarge := ImageY+sm_cysmicon ; the outerlimit for Y
if mouseX between %imageX% and %imageXlarge%
if mouseY between %imageY% and %imageYlarge%
return 0 ; if the mouse is over the designated icon
return 3 ; 3 means mouse not over the icon
}
WM_MOUSEMOVE()
{
global currButt, guiID
MouseGetPos,,,gID,kID
If(gID != guiID)
{ Return
}
currButt := kID
GuiControl,,%currButt%,in
tooltip,%currButt%
}
WM_MOUSELEAVE()
{
global currButt
GuiControl,,%currButt%,out
}
CheckForClick:
GetKeyState, vKey, %virtualkey%
If (vKey="D") and (debounce=0)
{ debounce=1
Gui, Show, NA
}
Return
;the following are from ahkosk
LeftClick(which) ;enable or disable left-click hotkey
{
If(which="on")
{ Hotkey, *LButton, On
Hotkey, *LButton up, On
}
Else
{ Hotkey, *LButton, Off
Hotkey, *LButton up, Off
}
}
*LButton:: ;map left click to the Virtual Key - VK does not stand for Voigt-Kampff
SetKeyDelay -1
Send {Blind}{%virtualkey% Down}
Return
*LButton up::
SetKeyDelay -1
Send {Blind}{%virtualkey% Up}
debounce=0
Return