blckpythn Posted April 16, 2010 Share Posted April 16, 2010 Opt("MouseCoordMode", 0) Opt("Pixelcoordmode", 0) Global $hot = HotKeySet("{SPACE}", "Pixelchecker") Func Pixelchecker() Local $mousepos = MouseGetPos() Local $pixelpos[4] $pixelpos[0] = $mousepos[0] - 5 ;left $pixelpos[1] = $mousepos[1] + 5 ;top $pixelpos[2] = $mousepos[0] + 5 ;right $pixelpos[3] = $mousepos[1] - 5 ;bottom $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) While $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) Sleep(50) WEnd MouseClick("left") EndFunc ;==>Pixelchecker So I got that far but my hotkeyset keeps running the function without me pressing space. Why would this be? Link to comment Share on other sites More sharing options...
Yoriz Posted April 16, 2010 Share Posted April 16, 2010 (edited) Don't know why its activating itself for you, i stripped out the code in the space hotkey function and added a loop to test it and works fine for me. Opt("MouseCoordMode", 0) Opt("Pixelcoordmode", 0) Global $Hot = HotKeySet("{SPACE}", "Pixelchecker") HotKeySet("{ESC}","_Exit") Func _Exit() MsgBox(0,"Finished","") Exit EndFunc Func Pixelchecker() MsgBox(0,"Pause","",1) EndFunc ;==>Pixelchecker While 1 WEnd edit - although you dont need the part Global $hot = , it still works if thats there. Edited April 16, 2010 by Yoriz GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn,First, please do not use the term AutoHotKey here - it can upset some people. Secondly, your code works fine for me - I added a ConsoleWrite line to show when we got to the waiting loop and it only fires if I press the HotKey:Opt("MouseCoordMode", 0) Opt("Pixelcoordmode", 0) HotKeySet("{SPACE}", "Pixelchecker") HotKeySet("{ESC}", "On_Exit") While 1 Sleep(10) WEnd Func Pixelchecker() Local $mousepos = MouseGetPos() Local $pixelpos[4] $pixelpos[0] = $mousepos[0] - 5 ;left $pixelpos[1] = $mousepos[1] + 5 ;top $pixelpos[2] = $mousepos[0] + 5 ;right $pixelpos[3] = $mousepos[1] - 5 ;bottom $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) ConsoleWrite("Entering waiting loop" & @CRLF) While $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) Sleep(500) WEnd MouseClick("left") EndFunc ;==>Pixelchecker Func On_Exit() Exit EndFuncIs this all the code or is there any more which might fire the function?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted April 16, 2010 Share Posted April 16, 2010 The guys are right Just remove "Global $hot = " before your hotkeyset. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 Declaring the variable Global $hot= was so i could call its return value with a msgbox to see if it was run or not. I tried it on another computer with the same results. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn,HotKeySet merely returns 1 or 0 to show whether it was susccessful, so there is nothing to store to "call its return value with a msgbox". You are aware that any use of the "Space" key once you have declared it as a HotKey will fire the function? Are you trying to use the "Space" key in another app with the script running? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 The instant I press F5 to test the script the msgbox pops up saying that it returned a 1 for HotKeySet, which means its running it right through (the msgbox was added to the last line of the script) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn,The instant I press F5 to test the script the msgbox pops up saying that it returned a 1 for HotKeySetThat is the HotKey being set, NOT the function being run - is that what is causing the confusion?When you run the code I posted earlier which included a ConsoleWrite, do you get the "Entering waiting loop" written in the SciTE console as soon as you press F5? Or do you have to press the "Space" key before it appears?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 (edited) No that wasn't the confusion. When I run yours I have to press space first. But it will not click. Are my mousepos conversion to checksum values wrong too? Edited April 16, 2010 by blckpythn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 blckpythn,Let us look at the logic flow of your script:1. You press the HotKey.2. You take a PixelCheckSum of ths colours around the mouse position at that moment.3. You wait until the PixelCheckSum changes.4. You click the mouse at that same point.So the mouse will only click when it gets out of this loop:While $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) Sleep(500) WEndDoes the area under the mouse position ever change colour to enable this?Or is the logic of the function wrong?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blckpythn Posted April 16, 2010 Author Share Posted April 16, 2010 I figured it out. I was moving the mouse to different colored pixels but the pixels from the original mouse position never changed. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2010 Moderators Share Posted April 16, 2010 (edited) Try this script. A small red square appears in the GUI, put the mouse over it and press "Space". 5 secs later the square changes to blue. I get the correct strings written in the SciTE console - do you? expandcollapse popup#include <GUIConstantsEx.au3> Opt("MouseCoordMode", 0) Opt("Pixelcoordmode", 0) HotKeySet("{SPACE}", "Pixelchecker") $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("", 10, 10, 20, 20) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState() ConsoleWrite("Ready!" & @CRLF) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Func Pixelchecker() Local $mousepos = MouseGetPos() Local $pixelpos[4] $pixelpos[0] = $mousepos[0] - 5 ;left $pixelpos[1] = $mousepos[1] + 5 ;top $pixelpos[2] = $mousepos[0] + 5 ;right $pixelpos[3] = $mousepos[1] - 5 ;bottom $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) ConsoleWrite("Entering waiting loop" & @CRLF) $ibegin = TimerInit() While $pixelcheck = PixelChecksum($pixelpos[0], $pixelpos[1], $pixelpos[2], $pixelpos[3]) Sleep(500) If TimerDiff($iBegin) > 5000 Then GUICtrlSetBkColor($hLabel, 0x0000FF) WEnd ConsoleWrite("I am now clicking" & @CRLF) MouseClick("left") EndFunc ;==>Pixelchecker M23 Edit: I see you have an answer - good. Edited April 16, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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