Nezoic Posted July 27, 2013 Share Posted July 27, 2013 (edited) So last night I wrote a script to find and image and click on, it work perfectly all night while testing. When I woke up this morning it not longer worked for some reason and I have no idea what couldn't changed. The script still finds the image, and right after I post a msgbox to make sure it hits that line of code and returns x,y, but the mouse click never fires It does however fire once if I click back to Scite? But only once since the window is not longer active, it's almost as if there is a setting in Scite that needs focus? Or maybe the window is all of a sudden blocking automated mouse clicks somehow? Any ideas? expandcollapse popup#include <ImageSearch.au3> Opt("MouseCoordMode", 1) $WinName = "TestWindow" $ImageLoc = "z:\dev\Images\TestImage.png" HotKeySet("{F2}", "ClickImage") HotKeySet("x", "Stop") $X= 0 $Y= 0 Main() Func Main() while 1 sleep(10) IF WinActive($WinName) Then ClickImage() EndIf wend EndFunc Func ClickImage() $result = _ImageSearch($ImageLoc ,1,$X,$Y,5) IF $result=1 Then MsgBox(0, "", "Found Image at" & $X& ":"& $Y) MouseMove($X, $Y) MouseClick("left") EndIf Sleep(100) EndFunc Func Stop() ;to allow the script to stop Exit EndFunc Edited July 27, 2013 by Nezoic Link to comment Share on other sites More sharing options...
Unc3nZureD Posted July 27, 2013 Share Posted July 27, 2013 (edited) Basically it shouldn't be problem, but try MouseClick ( "left", $x, $y ) Instead of: MouseMove($X, $Y) MouseClick("left") Edited July 27, 2013 by Unc3nZureD Link to comment Share on other sites More sharing options...
Nezoic Posted July 27, 2013 Author Share Posted July 27, 2013 Well I just figure out that it IS only when the window is active that non of the mouse click functions work. I made another function that just moves the mouse and attached it to a hot key which works unless this particular window is active. Very strange. Link to comment Share on other sites More sharing options...
czardas Posted July 27, 2013 Share Posted July 27, 2013 What happens if you remove he message box? operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Gianni Posted July 27, 2013 Share Posted July 27, 2013 hi try with 0 instead 1 as MouseCoordMode Opt("MouseCoordMode", 0) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Nezoic Posted July 28, 2013 Author Share Posted July 28, 2013 Thanks for the replies I put the message box in just as a test to make sure it was getting to that line of code. It happens with or without it. I also tried other MouseCoordMode options and it's the same result. The click only works whenever that window does NOT have focus / is active. If I click on another window or the desktop then it runs. I'm assuming there is something in that window that blocks calls to mouse functions, I may need to try the api route with SendMessage / PostMessage. Link to comment Share on other sites More sharing options...
czardas Posted July 28, 2013 Share Posted July 28, 2013 (edited) The reason I suggested it is that when you have a problem with window focus, then using ConsoleWrite would be better for trouble shooting than using msgbox which will take focus until clicked. Although it appears unrelated to your problem things like that might sometimes affect how the script runs. . . . maybe the window is all of a sudden blocking automated mouse clicks somehow? Perhaps this is true. Edited July 28, 2013 by czardas operator64 ArrayWorkshop 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