 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
psjw12
Joined: 10 May 2007 Posts: 25
|
Posted: Mon Oct 15, 2007 8:57 pm Post subject: Detect mouse hover on GUI |
|
|
I'm writing a program that uses a toaster but I want the window to be transparent but go solid when the user places the mouse over the GUI.
I know I could do:
| Code: |
Loop
{
MouseGetPos, , , Window,
If Window = "Toaster"
WinSet,Trans,255,Toaster
Else
WinSet,Trans,150,Toaster
Sleep,10
}
Return
|
but that slows the script down and seems to stop other threads from working.
I will also get round to making it fade in and out of solid rather than just a sudden transparency change.
Anyone can help? If you want I can post all I've done so far |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 971 Location: London, UK
|
Posted: Mon Oct 15, 2007 9:55 pm Post subject: |
|
|
There is an example of something you can do at the bottom of gui page, regarding monitoring wm_mousemove.
Ill try and find it for you.
Edit:
This could be eaily modified to suit your purpose.
| Code: | Gui, Add, Edit, vMyEdit
MyEdit_TT := "This is a tooltip for the control whose variable is MyEdit."
Gui, Add, DropDownList, vMyDDL, Red|Green|Blue
MyDDL_TT := "Choose a color from the drop-down list."
Gui, Add, Checkbox, vMyCheck, This control has no tooltip.
Gui, Show
OnMessage(0x200, "WM_MOUSEMOVE")
return
WM_MOUSEMOVE()
{ static CurrControl, PrevControl, _TT ; _TT is kept blank for use by the ToolTip command below.
CurrControl := A_GuiControl
If (CurrControl <> PrevControl and not InStr(CurrControl, " "))
{
ToolTip ; Turn off any previous tooltip.
SetTimer, DisplayToolTip, 1000
PrevControl := CurrControl
}
return
DisplayToolTip:
SetTimer, DisplayToolTip, Off
ToolTip % %CurrControl%_TT ; The leading percent sign tell it to use an expression.
SetTimer, RemoveToolTip, 3000
return
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
}
|
The function is launched whenever the mouse moves over the gui window. You could check if its the right one with a_gui _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
psjw12
Joined: 10 May 2007 Posts: 25
|
Posted: Mon Oct 15, 2007 10:09 pm Post subject: |
|
|
Tried that but didn't work. Don't know if you can mix it with my code.
The script is...
| Code: | #NoEnv
SysGet,TStartH,MonitorWorkArea, ;get area to place toaster
Gui,Add,Text,,Sample Text
xPos := TStartHRight - 202
yPos := TStartHBottom -102
Gui, -0x400000 -MinimizeBox -SysMenu +ToolWindow ;makes with black boarder
Gui,Show,x%xPos% y%yPos% w200 h100,Toaster
WinSet,Trans,150,Toaster,
++TStartHBottom ;need this to make bottom of window touch the start bar
Loop,103 ;slides from bottom screen up
{
--TStartHBottom
Gui,Show,x%xPos% y%TStartHBottom%,
Sleep,5
}
Sleep,3000
Loop,203 ;slides off to the right
{
Gui,Show,x%xPos% y%TStartHBottom%,
++xPos
Sleep,5
}
ExitApp
GuiClose:
ExitApp |
|
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 971 Location: London, UK
|
Posted: Mon Oct 15, 2007 10:24 pm Post subject: |
|
|
| Code: | #NoEnv
SysGet,TStartH,MonitorWorkArea, ;get area to place toaster
Gui,Add,Text,,Sample Text
xPos := TStartHRight - 202
yPos := TStartHBottom -102
Gui, -0x400000 -MinimizeBox -SysMenu +ToolWindow ;makes with black boarder
Gui,Show,x%xPos% y%yPos% w200 h100 noactivate,Toaster
OnMessage(0x200, "WM_MOUSEMOVE")
WinSet,Trans,150,Toaster,
++TStartHBottom ;need this to make bottom of window touch the start bar
Loop,103 ;slides from bottom screen up
{
--TStartHBottom
Gui,Show,x%xPos% y%TStartHBottom% Noactivate,
Sleep,5
}
Sleep,3000
Loop,203 ;slides off to the right
{
Gui,Show,x%xPos% y%TStartHBottom% Noactivate,
++xPos
Sleep,5
}
ExitApp
GuiClose:
ExitApp
WM_MOUSEMOVE()
{
Static winstate
if not winstate
{
WinSet,Trans,255,Toaster,
WinSet,Trans,off,Toaster,
}
winstate:=1
} |
This works for me.[/code] _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
psjw12
Joined: 10 May 2007 Posts: 25
|
Posted: Mon Oct 15, 2007 10:34 pm Post subject: |
|
|
It detects when the mouse is over but not when it leaves... will I need to use WM_MOUSELEAVE = 0x2A3 ?
Do you know how to write these in because I'm useless at them.
Cheers!!! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|