GuiCtrlSetOnHover()?
#1
Posted 22 September 2007 - 09:51 PM
It seems inefficient to me to have a script constantly checking the mouse position to see if it's hovering, although it works great for me! However, I was just wondering if this would be at all possible.
#2
Posted 05 October 2007 - 12:09 AM
But what is impoarant is this part
$mouse=GUIGetCursorInfo() if $mouse[4]=$CONTROL_ID then Msgbox(0,"Your Hovering", "Over the control" ) Endif if $mouse[4]<>$CONTROL_ID then Msgbox(0,"Your Hovering", "not Over the control" ) Endif
This was pulled out of a program my buddy made
$msg = GUIGetMsg() $mouse=GUIGetCursorInfo() while @error=0 if $mouse[4]=$PU then GUICtrlSetimage( $PU, "PU2.BMP") if $mouse[4]<>$PU then GUICtrlSetimage( $PU, "PU.BMP") if $mouse[4]=$SUBMenu[0] then GUICtrlSetimage( $SUBMenu[0], "PU2.BMP") if $mouse[4]=$SUBMenu[1] then GUICtrlSetimage( $SUBMenu[1], "PU2.BMP") if $mouse[4]=$SUBMenu[2] then GUICtrlSetimage( $SUBMenu[2], "PU2.BMP") if $mouse[4]=$SUBMenu[3] then GUICtrlSetimage( $SUBMenu[3], "PU2.BMP") if $mouse[4]<>$SUBMenu[0] then GUICtrlSetimage( $SUBMenu[0], "PU.BMP") if $mouse[4]<>$SUBMenu[1] then GUICtrlSetimage( $SUBMenu[1], "PU.BMP") if $mouse[4]<>$SUBMenu[2] then GUICtrlSetimage( $SUBMenu[2], "PU.BMP") if $mouse[4]<>$SUBMenu[3] then GUICtrlSetimage( $SUBMenu[3], "PU.BMP") exitloop wend
What it did was it changed the picture if you were hovering over the control

#3
Posted 05 October 2007 - 12:14 AM
Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
#4
Posted 05 October 2007 - 01:37 AM
There is, and you could, but it's questionable if it's really worth it in the end... when GUIGetCursorInfo does it all for you.I haven't checked in some time, but I believe there is a WM_MOUSEHOVER ... if that is true then you could use GUIRegisterMsg() and some custom mousegetpos/childgetwinfrompoint function. Would be interesting to see what you turn out.
You need to call TrackMouseEvent each time that message pops. If you want to be more efficient, you need to subclass the control to catch its WM_MOUSEHOVER messages, because trying to work out control hover using WM_MOUSEHOVER of the main window isn't all that different from polling GUIGetCursorInfo in your main loop.
I did some WM_MOUSELEAVE tracking in one of my AutoIt apps, to get when the mouse enters/leaves window, and it worked, but then I ditched whole concept for the sake of simplicity.
#5
Posted 05 October 2007 - 01:38 AM
The TrackMouseEvent function posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time.
...
The mouse pointer is considered to be hovering when it stays within a specified rectangle for a specified period of time. Call SystemParametersInfo. and use the values SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEHOVERHEIGHT, and SPI_GETMOUSEHOVERTIME to retrieve the size of the rectangle and the time.
So I'm not sure this is exactly what he's looking for.
#6
Posted 05 October 2007 - 02:07 AM
It would be WM_MOUSEMOVE...There is, but it looks a little more complicated than that...
So I'm not sure this is exactly what he's looking for.
And customizing "per" gui would be no problem using what I stated... the issue is making it a CallBack (now possible thanks to piccaso I believe) and being able to globally store all the options.
Personally, I wouldn't look forward to writing it to be universal... but it might be up your alley with what you were doing just recently http://www.autoitscript.com/forum/index.ph...c=53390&hl= ... I would think using Call() ... a few globals ... and a callback and you could make it universal with what I suggested...
*** Again, these are just thoughts, I haven't actually sat down to test any of it, but I'm fairly confident I could make it work with RegisterMsg() + a function to work on the WM_MOUSEMOVE with just my own GUI and knowing what was going to be called and what needed changing when called (<< That last part is where I stopped thinking
Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
#7
Posted 05 October 2007 - 02:16 AM
@The rest: What Smoke_N said sounds like a good option. Like the GuiRegisterMsg()... However, I would have NO idea whatsoever how to do this and I don't have time to learn
If anybody has time and gets it to work it would be sweet!
#8
Posted 06 October 2007 - 08:45 AM
Once you get your head around the simple fact that Control ID's are just numbers (something the manual doesn't really nail - the GUIGetCursorInfo() page would be good), it's all quite easy to implement. Here's the main loop, whith a whole lotta hovering going on..
; main loop.. ; while not $do_quit if $do_func <> "" then Call($do_func) endif sleep(75) local $mouse_info = GUIGetCursorInfo() ; help file page for this command needs a decent hover example! ; in fact, *any* decent examples would be good. if $mouse_info = 0 then $left_window = true cpc_UnSetHotKeys() else cpc_SetHotKeys() if $super_mag and $left_window = true then ; back inside the gui cpc_SwitchOffSuperMag() endif $left_window = false endif if not IsArray($mouse_info) then continueloop ; outside gui local $MousePos = MouseGetPos() if not IsArray($MousePos) then continueloop ; inside picker, grad, or mag (or dragable info label).. if $mouse_info[4] = $pic_color_picker or $mouse_info[4] >= $info_dummy then if $mouse_info[4] = $info_dummy or $mouse_info[4] = $label_colorwell then ; it's trivial to check which control you are hovering over GUISetCursor(9, 1, $gui_color) ; feel free to use something like this for the GUIGetCursorInfo() manual page. continueloop ; no credit required! ;o) endif GUISetCursor(3, 1, $gui_color) ; "+" $cpc_live_color = StringRight(Hex(PixelGetColor($MousePos[0],$MousePos[1])), 6) cpc_UpdateLiveColorBox() ; hold down left mouse button for live effects.. if $live_luminance = $GUI_CHECKED or ce_IsPressed(01) then cpc_UpdateLumGrad($cpc_live_color) if $live_mag = $GUI_CHECKED or ce_IsPressed(01) then cpc_UpdateMag() if $live_hex = $GUI_CHECKED then if ce_IsPressed(10) then ToolTip(ConvertColorValue($cpc_live_color, $cpc_output_mode, $add_prefix), $MousePos[0]+2, $MousePos[1]+2) else ToolTip($cpc_live_color, $MousePos[0]+2, $MousePos[1]+2) endif endif $color_set = 1 elseif $super_mag then cpc_UpdateMag() GUISetCursor(3, 1, $gui_color) else ; outside picker areas or window.. GUISetCursor() ToolTip ("") if $color_set = 1 then if $hold_live_color = $GUI_UNCHECKED then GUICtrlSetBkColor($label_live_color, "0x" & $cpc_my_color) if $live_luminance = $GUI_CHECKED then cpc_UpdateLumGrad($cpc_my_color) endif $color_set = 0 endif endif wend
;o)
(or
#9
Posted 11 October 2007 - 03:49 PM
I have been using Xskin to do this but I have encountered a Major flaw with Xskin and all other hover scripts I have found.
If you have a combo box dropped down and displaying over a button and you select an item that is imediatly over the button, the button gets clicked.
It should be as simple as copying the GuiCtrlSetOnEvent code and just make a function that looks for a Mouseover command instead of a click.
Mike
Edited by MikeOsdx, 11 October 2007 - 03:50 PM.
#10
Posted 14 October 2007 - 05:26 AM
Here is the standard method (Not work with Labels, inputs/edits and maybe more controls):
;NOT WORK WITH LABEL, INPUT, OR EDIT CONTROL! #include <GuiConstants.au3> Global Const $WM_NOTIFY = 0x004E Global $HOVER_CONTROLS_ARRAY[1][1] GuiCreate("Test") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $Button = GUICtrlCreateButton("Button", 20, 40, 70, 20) GUICtrlSetOnHover($Button, "My_Hover_Func") $CheckBox = GUICtrlCreateCheckbox("CheckBox", 20, 80, 70, 20) GUICtrlSetOnHover($CheckBox, "My_Hover_Func") GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit EndSwitch WEnd Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam) If UBound($HOVER_CONTROLS_ARRAY)-1 < 1 Then Return $GUI_RUNDEFMSG Local $CursorInfo = GUIGetCursorInfo($hWndGUI) If $CursorInfo[4] = 0 Then Printf("No Hovered Controls") Return $GUI_RUNDEFMSG EndIf For $i = 1 To $HOVER_CONTROLS_ARRAY[0][0] If $HOVER_CONTROLS_ARRAY[$i][0] = GUICtrlGetHandle($CursorInfo[4]) Then Call($HOVER_CONTROLS_ARRAY[$i][1], $CursorInfo[4]) ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func GUICtrlSetOnHover($CtrlID, $FuncName) Local $Ubound = UBound($HOVER_CONTROLS_ARRAY) ReDim $HOVER_CONTROLS_ARRAY[$Ubound+1][2] $HOVER_CONTROLS_ARRAY[$Ubound][0] = GUICtrlGetHandle($CtrlID) $HOVER_CONTROLS_ARRAY[$Ubound][1] = $FuncName $HOVER_CONTROLS_ARRAY[0][0] = $Ubound EndFunc Func My_Hover_Func($CtrlID) Printf("Control " & $CtrlID & " [Data: " & GUICtrlRead($CtrlID, 1) & "] Is Now Hovered") EndFunc ;Debug Function Func Printf($Str, $Line=@ScriptLineNumber) ConsoleWrite("!===========================================================" & @LF & _ "+======================================================" & @LF & _ "--> Script Line (" & $Line & "):" & @LF & "!" & @TAB & $Str & @LF & _ "+======================================================" & @LF) EndFuncoÝ÷ ØÆ²m謥vëXÃQ!9Q!z·ºØÁ«,+ex Ý êÞËax&¥gp¢¹0ØZX)äþ)yÊ'¶º%²+wöƦ¹ÈiçÞçfzØhu«¢+Ø¥¹±Õ±Ðí±± ±± ¬¹ ÔÌÐì()±½ °ÀÌØí!=YI} =9QI=1M}IIelÅulÅt)±½ °ÀÌØíÁQ¥µÉAɽô}±± ±± ¬ ÅÕ½Ðí 11 -AI=ÅÕ½Ðì°ÅÕ½Ðí¡Ý¹íÕ¥¹ÐíÕ¥¹ÐíݽÉÅÕ½Ðì¤)±½ °ÀÌØíÕ¥Q¥µÈô±± ±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½ÐíÕ¥¹ÐÅÕ½Ðì°ÅÕ½ÐíMÑQ¥µÈÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°À°ÅÕ½ÐíÕ¥¹ÐÅÕ½Ðì°À°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÄÀ°ÅÕ½ÐíÁÑÈÅÕ½Ðì°ÀÌØíÁQ¥µÉAɽ¤(ÀÌØíÕ¥Q¥µÈôÀÌØíÕ¥Q¥µÉlÁt()Õ¥ É Ñ ÅÕ½ÐíU% ÑɱMÑ=¹!½ÙÈ5
The DllCallBack.au3 you can find here.
==========================================================
AutoIt Russian Community
Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program
UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating
)* === My topics === *
==========================================================AutoIt is simple, subtle, elegant. © AutoIt Team
#11
Posted 14 October 2007 - 06:10 AM
==========================================================
AutoIt Russian Community
Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program
UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating
)* === My topics === *
==========================================================AutoIt is simple, subtle, elegant. © AutoIt Team
#12
Posted 14 October 2007 - 11:48 PM
I don't have the problem with activating controls under drop-downs, either.
Why all the complexity? Am I missing something?
;o)
(or
#13
Posted 15 October 2007 - 12:03 AM
What you use requires the code to be constantly checking to see if something is hovered. The new was that MsCreator put together notifies you when you hover over something and immediately does a function.THIS IS ALREADY BUILT-IN TO AUTOIT!
I don't have the problem with activating controls under drop-downs, either.
Why all the complexity? Am I missing something?
;o)
(or
For example... would you rather check every second to see if the time is 5:30 by looking at your watch or just set an alarms for 5:30?
#14
Posted 16 October 2007 - 07:26 PM
Though better examples in the manual would be good.
;o)
(or
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users






