dbzfanatic Posted September 12, 2007 Share Posted September 12, 2007 (edited) How do I call a function whenever the mouse moves? It works fine once when I start the loop but only once.#RequireAdmin #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Michael\Documents\pixeltest form.kxf $Form1 = GUICreate("Color Getter", 448, 174, 193, 115) $Graphic1 = GUICtrlCreateGraphic(280, 0, 161, 161) $Label1 = GUICtrlCreateLabel("The color of the cursor position is: ", 280, 128, 161, 30) $btnStart = GUICtrlCreateButton("Start the find process", 8, 16, 113, 17, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnStart Check() EndSwitch WEnd Func Check() Do $array = MouseGetPos() $color = PixelGetColor($array[0], $array[1]) GUICtrlSetBkColor($Graphic1, $color) GUICtrlSetBkColor($Label1, $color) GUICtrlSetData($Label1,"The color of the cursor position is: " & $color) Until $GUI_EVENT_CLOSE EndFuncif it's in the help file please don't go all on me, just point me to the proper function.Edit: works when i have until 0>1 (infinite loop) but the GUI won't close this way. Edited September 12, 2007 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
James Posted September 12, 2007 Share Posted September 12, 2007 Try storing the mouse location first then in a loop compare the two places and if they are different then take an action Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 12, 2007 Author Share Posted September 12, 2007 I thought about that but I was hoping there was a builtinfunction. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
qazwsx Posted September 12, 2007 Share Posted September 12, 2007 also u could but ur _check func in case else so u can loop it but still close the gui. Link to comment Share on other sites More sharing options...
_Kurt Posted September 12, 2007 Share Posted September 12, 2007 I have an idea $Pos = MouseGetPos() While 1 $Pos2 = MouseGetPos() If $Pos[0] <> $Pos2[0] OR $Pos[1] <> $Pos2[1] Then MsgBox(0,"","Moved.") $Pos = MouseGetPos() EndIf Sleep(5) WEnd Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 13, 2007 Author Share Posted September 13, 2007 Thanks for all the help guys/girls, I guess there isn't really a built-in function so I'll have to do it the hard way thanks for the input and code snipets. It's very much appreciated . Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Toady Posted September 13, 2007 Share Posted September 13, 2007 Thanks for all the help guys/girls, I guess there isn't really a built-in function so I'll have to do it the hard way thanks for the input and code snipets. It's very much appreciated .You could use larrys mousehook to do this. Check out the source code in MacroGamer in my signature..... I have it calling a function when mouse moves to record mouse movements. www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 13, 2007 Author Share Posted September 13, 2007 There was a thread earlier about mousehook and it looked interesting but I don't know what it does, if you'd explain it to me I'd more than happily give it a look. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Toady Posted September 13, 2007 Share Posted September 13, 2007 Mousehook is a DLL that can give you global keyboard and mouse hooking. You can register the mouse normally in your script but it will only be local to that script. Just looking in MacroGamer.au3 and scroll to very bottom. All the code needed is there. You will also find kh.dll in the same place MacroGamer.zip is in. Hope that helps. www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Uten Posted September 13, 2007 Share Posted September 13, 2007 Have not checked, but I think @Larry has removed the MouseHook posts and links? Using MouseGetPos() should be better as you can control the polling frequency? Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now