gLabel on Mouse Over Topic is solved
gLabel on Mouse Over
Hello, i cant find anything online about this so im not sure if this is possible, but is there a way to trigger a glabel when the mouse goes over a visible GUI?
Re: gLabel on Mouse Over Topic is solved
Code: Select all
Global hWnd
Gui, +HwndhWnd
Gui, Add, Text, w250 h50, GUI
Gui, Show
OnMessage(0x0200, "WM_MOUSEMOVE")
WM_MOUSEMOVE(wParam, lParam) {
Static in
If in
Return
ToolTip, In!
in := True
SoundBeep, 1500
SetTimer, Check, 200
Return
Check:
CoordMode, Mouse
WinGetPos, x1, y1, width, height, ahk_id %hWnd%
x2 := x1 + width, y2 := y1 + height
MouseGetPos, x, y
If x between %x1% and %x2%
If y between %y1% and %y2%
Return
SetTimer,, Off
ToolTip, Out!
SoundBeep, 1000
in := False
Return
}
Re: gLabel on Mouse Over
thank you works well when implemented with me other script
Re: gLabel on Mouse Over
Possibly an improvement:
Code: Select all
Global hWnd
Gui, +HwndhWnd
Gui, Add, Text, w250 h50, GUI
Gui, Show
hoverTrigger()
overGUI(wParam, lParam) {
hoverTrigger(False)
ToolTip, In!
SoundBeep, 1500
SetTimer, Check, 200
Return
Check:
CoordMode, Mouse
WinGetPos, x1, y1, width, height, ahk_id %hWnd%
x2 := x1 + width, y2 := y1 + height
MouseGetPos, x, y
If x between %x1% and %x2%
If y between %y1% and %y2%
Return
SetTimer,, Off
hoverTrigger()
ToolTip, Out!
SoundBeep, 1000
Return
}
hoverTrigger(maxThreads := 1) {
OnMessage(WM_MOUSEMOVE := 0x0200, "overGUI", maxThreads) ; Client area
OnMessage(WM_NCMOUSEMOVE := 0x00A0, "overGUI", maxThreads) ; Non-client area
}
-
- Posts: 864
- Joined: 21 Dec 2015, 02:34
Re: gLabel on Mouse Over
This is excellent! One question:mikeyww wrote: ↑03 Feb 2022, 20:23Possibly an improvement:
Code: Select all
Global hWnd Gui, +HwndhWnd Gui, Add, Text, w250 h50, GUI Gui, Show hoverTrigger() overGUI(wParam, lParam) { hoverTrigger(False) ToolTip, In! SoundBeep, 1500 SetTimer, Check, 200 Return Check: CoordMode, Mouse WinGetPos, x1, y1, width, height, ahk_id %hWnd% x2 := x1 + width, y2 := y1 + height MouseGetPos, x, y If x between %x1% and %x2% If y between %y1% and %y2% Return SetTimer,, Off hoverTrigger() ToolTip, Out! SoundBeep, 1000 Return } hoverTrigger(maxThreads := 1) { OnMessage(WM_MOUSEMOVE := 0x0200, "overGUI", maxThreads) ; Client area OnMessage(WM_NCMOUSEMOVE := 0x00A0, "overGUI", maxThreads) ; Non-client area }
if we hover the cursor ontop of the "In!" and "Out!" tooltips, then the beeps also happen. Is there a way to prevent that from happening?
Re: gLabel on Mouse Over
That's an interesting point. Add as the first lines of overGUI:
You then have the following.
It's been done many times earlier, using similar approaches.
viewtopic.php?p=431609#p431609
viewtopic.php?p=391784#p391784
Here it is using the window class.
Code: Select all
If !A_Gui
Return
Code: Select all
Global hWnd
Gui, +HwndhWnd
Gui, Add, Text, w250 h50, GUI
Gui, Show
hoverTrigger()
overGUI(wParam, lParam) {
If !A_Gui
Return
hoverTrigger(False)
ToolTip, In!
SoundBeep, 1500
SetTimer, Check, 200
Return
Check:
CoordMode, Mouse
WinGetPos, x1, y1, width, height, ahk_id %hWnd%
x2 := x1 + width, y2 := y1 + height
MouseGetPos, x, y
If x between %x1% and %x2%
If y between %y1% and %y2%
Return
SetTimer,, Off
hoverTrigger()
ToolTip, Out!
SoundBeep, 1000
Return
}
hoverTrigger(maxThreads := 1) {
OnMessage(WM_MOUSEMOVE := 0x0200, "overGUI", maxThreads) ; Client area
OnMessage(WM_NCMOUSEMOVE := 0x00A0, "overGUI", maxThreads) ; Non-client area
}
viewtopic.php?p=431609#p431609
viewtopic.php?p=391784#p391784
Here it is using the window class.
Code: Select all
Gui, Add, Text, w250 h50, GUI
Gui, Show
hoverTrigger() ; Call overScript() if mouse goes "over the script"
overScript(wParam, lParam) {
If !A_Gui ; Mouse is not over the GUI itself
Return
hoverTrigger(False) ; Mouse is over GUI; stop calling this function
ToolTip, In!
SoundBeep, 1500
SetTimer, Check, 200 ; Start check to see when mouse leaves the GUI
Return
Check:
MouseGetPos,,, uid
WinGetClass, class, ahk_id %uid% ; Window class under the mouse
If (class = "AutoHotkeyGUI") ; Mouse is over the GUI
Return
SetTimer,, Off ; Mouse is not over GUI; stop monitoring
hoverTrigger() ; Reactivate the GUI hover trigger
ToolTip, Out!
SoundBeep, 1000
Return
}
hoverTrigger(maxThreads := 1) {
OnMessage(WM_MOUSEMOVE := 0x0200, "overScript", maxThreads) ; Client area
OnMessage(WM_NCMOUSEMOVE := 0x00A0, "overScript", maxThreads) ; Non-client area
}
-
- Posts: 864
- Joined: 21 Dec 2015, 02:34
Re: gLabel on Mouse Over
This is really nice. It reminds me of another script I have tucked away that will scroll a Google Chrome window when the cursor is inside of the GUI:
...but the only problem with this one is that while the cursor must be inside the GUI for the scrolling to work, it must also be moving at all times. If the cursor stops moving, then the scrolling stops.
Code: Select all
#NoEnv
#SingleInstance Force
Critical
OnMessage(0x200, "onMouseMove")
Gui, +AlwaysOnTop
Gui, Show, w225 h75
Return
GuiClose:
ExitApp
onMouseMove(wParam, lParam, msg, hwnd) {
static
x := lParam & 0xFFFF
y := lParam >> 16
if (x!=x2 and y!=y2)
{
winactivate, ahk_exe chrome.exe
sendinput {down 4}
x2 := x , y2 := y
}
return
}
...but the only problem with this one is that while the cursor must be inside the GUI for the scrolling to work, it must also be moving at all times. If the cursor stops moving, then the scrolling stops.
-
- Posts: 864
- Joined: 21 Dec 2015, 02:34
Re: gLabel on Mouse Over
This script will scroll a Google Chrome window when the cursor is ontop of the GUI but the difference is that it uses a timer. Still works nicely though. Perhaps someone might have a use for it.
Code: Select all
Gui 1: +HwndIdTest +AlwaysOnTop +ToolWindow -dpiScale
Gui 1: Show, x200 y200 w300 h300, TEST
SetTimer, onout, 25
Return
onout:
MouseGetPos mx, my, IdWindow
WinGetTitle, WinT, ahk_id %IdWindow%
If (IdWindow = IdTest)
{
;The cursor is hovering over the GUI
winactivate, ahk_exe chrome.exe
sendinput {down}
}
Else If (IdWindow <> IdTest)
{
;The cursor is not hovering over the GUI
Return
}
Return
-
- Posts: 864
- Joined: 21 Dec 2015, 02:34
Re: gLabel on Mouse Over
I'm really liking this one. I just have one more question if I may: is there a way to hover on top of/grab+drag the title bar without the functions triggering? So in other words the cursor would need to be inside the gui for everything to work but when the cursor is ontop of the title bar nothing would happen (except for the regular behavior of dragging the gui):
Code: Select all
Gui, Add, Text, w250 h50, GUI
Gui, Show
hoverTrigger() ; Call overScript() if mouse goes "over the script"
overScript(wParam, lParam) {
If !A_Gui ; Mouse is not over the GUI itself
Return
hoverTrigger(False) ; Mouse is over GUI; stop calling this function
ToolTip, In!
SoundBeep, 1500
SetTimer, Check, 200 ; Start check to see when mouse leaves the GUI
Return
Check:
MouseGetPos,,, uid
WinGetClass, class, ahk_id %uid% ; Window class under the mouse
If (class = "AutoHotkeyGUI") ; Mouse is over the GUI
Return
SetTimer,, Off ; Mouse is not over GUI; stop monitoring
hoverTrigger() ; Reactivate the GUI hover trigger
ToolTip, Out!
SoundBeep, 1000
Return
}
hoverTrigger(maxThreads := 1) {
OnMessage(WM_MOUSEMOVE := 0x0200, "overScript", maxThreads) ; Client area
OnMessage(WM_NCMOUSEMOVE := 0x00A0, "overScript", maxThreads) ; Non-client area
}
Re: gLabel on Mouse Over
You can remove the non-client OnMessage.
-
- Posts: 864
- Joined: 21 Dec 2015, 02:34
Re: gLabel on Mouse Over
ok, it works. this is going to be super useful, thanks for this
Who is online
Users browsing this forum: Bing [Bot] and 170 guests