AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detect mouse hover on GUI

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
psjw12



Joined: 10 May 2007
Posts: 25

PostPosted: Mon Oct 15, 2007 8:57 pm    Post subject: Detect mouse hover on GUI Reply with quote

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
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 971
Location: London, UK

PostPosted: Mon Oct 15, 2007 9:55 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
psjw12



Joined: 10 May 2007
Posts: 25

PostPosted: Mon Oct 15, 2007 10:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 971
Location: London, UK

PostPosted: Mon Oct 15, 2007 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
psjw12



Joined: 10 May 2007
Posts: 25

PostPosted: Mon Oct 15, 2007 10:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group