PanStefan Posted September 16, 2014 Share Posted September 16, 2014 Hello, last time my topic was closed, so I decide to do something diffrent. I want my script to find the photograph and moved the mouse incessantly into places which I want, all the way to the moment of finding other photograph which would finish the loop. At this moment I have only this, but it isn't work as I want, so can you help me with that? #RequireAdmin #include <ImageSearch.au3> Global $y, $x $stop = _ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255) HotKeySet("{p}", "checkForImage") While 1 Sleep(10) WEnd Func checkForImage() Do Sleep(10) $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 1, $x, $y, 255) If $search = 1 Then ContinueLoop Else MouseMove(0, 0) Sleep(1000) MouseMove(69, 69) Return $search EndIf Until _ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255) EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted September 16, 2014 Share Posted September 16, 2014 How is it work as you want? 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...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 I guess you didn't read. "I want my script to find the photograph and moved the mouse incessantly into places which I want, all the way to the moment of finding other photograph which would finish the loop." Link to comment Share on other sites More sharing options...
JohnOne Posted September 16, 2014 Share Posted September 16, 2014 I read just fine. you never said what the problem is. 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...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 I guess you didn't read. "I want my script to find the photograph and moved the mouse incessantly into places which I want, all the way to the moment of finding other photograph which would finish the loop." I will say, "places which I want" is not somewhere we know. Also, not sure if I understand "all the way to the moment of finding other photograph which would finish the loop". Any chance you can be more descriptive? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 Don't be mad, guys, I'm from Poland and I am making linguistic mistakes I'll try ofc. I would like to he finds the image and move mouse to points (0, 0 ; 69, 69) until he find another image. Link to comment Share on other sites More sharing options...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 (edited) Don't be mad, guys, I'm from Poland and I am making linguistic mistakes I'll try ofc. I would like to he finds the image and move mouse to points (0, 0 ; 69, 69) until he find another image. We are definitely not mad just explaining that's all. Completely understand language barrier. For one, the return statement in the Do...Until loop will take it out of the function all together. Also, you continue the loop when _ImageSearch returns a 1, which means it is successful. You need to change the conditional to If $search = 0 Then That should get you started. Also, set $x and $y to 0 before you use them. Even then, I don't know if using the Do...Until loop is your best bet. Your trying to find out if the image is found on the desktop and when you find it you should go to the next one, not stop the loop and run _ImageSearch(). Edited September 16, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 Oh boy I got confused Can you help me with this loop? I ask you to say straight to me, like to the child, because I didn't understand the majority what you talked about. :c Link to comment Share on other sites More sharing options...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 I will write an example. Are the only two images you are trying to _imageSearch() dll.bmp & checkImage.bmp? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 Soo.. I guess I will add more images in future But only in this $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 1, $x, $y, 255) Link to comment Share on other sites More sharing options...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 (edited) Then why put this line in _ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255) ? Here is an example. Give this a try.. #RequireAdmin #include <ImageSearch.au3> Global $y = 0, $x = 0 HotKeySet("{p}", "checkForImage") While 1 Sleep(10) WEnd Func checkForImage() $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 1, $x, $y, 255) If $search <> 0 Then Sleep(250) MouseMove(69, 69) Else MsgBox(0, "error", "Did not find anything") EndIf EndFunc ;==>checkForImage I'm hoping one of the gurus will chime in, as my knowledge of _ImageSearch() is small. Edited September 16, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 (edited) Mouse is going to that point even if that image isn't find. Then why put this line in _ImageSearch(@ScriptDir & "dll.bmp", 1, $x, $y, 255) ? Cuz I want to stop finding and moving mouse to point image named checkImage.bmp when image dll.bmp will be find Edited September 16, 2014 by Pan69Stefan Link to comment Share on other sites More sharing options...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 change If $search <> 0 Then to If $search = 1 Then Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 Okay. I don't know what I'm doing wrong, but when I'm pressing P only "error" msg pops up. Link to comment Share on other sites More sharing options...
MikahS Posted September 16, 2014 Share Posted September 16, 2014 (edited) Is checkImage.bmp in the same directory as your script? Put MsgBox(0, "", $search) ; put this after $search = _ImageSearch()... Post what the MsgBox shows for $search. We have the conditional right, that 1 = success. Edited September 16, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 16, 2014 Author Share Posted September 16, 2014 Yup. Msg says 1. But it's still one question I want to ask. ImageSearch is searching Image ONLY on desktop? What if I'll cover that image? Will mouse go to point anyway? Link to comment Share on other sites More sharing options...
Shinitenshi Posted September 17, 2014 Share Posted September 17, 2014 Yup. Msg says 1. But it's still one question I want to ask. ImageSearch is searching Image ONLY on desktop? What if I'll cover that image? Will mouse go to point anyway? Yes, if the image is being covered your script will return the value of "0" aka not found. If you have multiple monitors then it will only search your main / primary. Link to comment Share on other sites More sharing options...
PanStefan Posted September 17, 2014 Author Share Posted September 17, 2014 Something is wrong. When I change this $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 0, $x, $y, 255) (It's "finding" image even if it's covered by something) on this $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 0, $x, $y, 10) Msg pops up "error". So what parameter 10 or 255 means? Link to comment Share on other sites More sharing options...
MikahS Posted September 17, 2014 Share Posted September 17, 2014 (edited) parameters of _ImageSearch(): ($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance, $HBMP=0) Edited September 17, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
PanStefan Posted September 17, 2014 Author Share Posted September 17, 2014 What $HBMP=0 and $tolerance means? Yup, I am newbie :C 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