qweeztar Posted July 28, 2014 Share Posted July 28, 2014 (edited) #include <ImageSearch.au3> HotKeySet("s", "Start") $X = 0 $Y = 0 Func Start() $Search = _ImageSearch('1.bmp', 0, $X, $Y, 0) if $Search = 1 Then MouseMove($X, $Y, 10) EndIf EndFunc while 1 sleep(100) WEnd Windows 8, 64bit if that matters. I'm simply trying to make a simple macro to move the mouse to a specific place when the image is available. Any help? I'm trying to macro an account creation on a website. No, it's not for a game. Edited July 28, 2014 by qweeztar Link to comment Share on other sites More sharing options...
AutID Posted July 28, 2014 Share Posted July 28, 2014 What is your problem? What is not working? What is the error? Where are my keys? Where is my phone? There are a lot of unanswered question in the universe. But on the other hand, there are a lot of stupid questions. So it better stays this way. Welcome to the forum even if I don't believe that you are a newcomer! A small tip is to use IE UDF since you are automating a website. Or better, WinHttp UDF. Do yourself a favor, search. 13lack13lade 1 https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Zedna Posted July 28, 2014 Share Posted July 28, 2014 In the topic of ImageSearch UDF there is mentioned fix for 64bit systems as far as I know ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
qweeztar Posted July 28, 2014 Author Share Posted July 28, 2014 (edited) What is your problem? What is not working? What is the error? Where are my keys? Where is my phone? There are a lot of unanswered question in the universe. But on the other hand, there are a lot of stupid questions. So it better stays this way. Welcome to the forum even if I don't believe that you are a newcomer! A small tip is to use IE UDF since you are automating a website. Or better, WinHttp UDF. Do yourself a favor, search. Tried to get my old account back, but I waited around 2 hours for an password reset link but it never arrived so I gave up that hope and created a new account. Also, to answer your question. The problem is that nothing happens. I'm not getting an error, but the program isn't moving the mouse either. Edited July 28, 2014 by qweeztar Link to comment Share on other sites More sharing options...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 It looks likethe problem is the way you have it looping. Try this: #include <ImageSearch.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{HOME}", "Terminate") $Paused = $Paused send("{pause}") $X = 0 $Y = 0 While 1 Start() WEnd Func Start() $Search = _ImageSearch('1.bmp', 0, $X, $Y, 0) if $Search = 1 Then MouseMove($X, $Y, 10) EndIf EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
qweeztar Posted July 29, 2014 Author Share Posted July 29, 2014 (edited) It looks likethe problem is the way you have it looping. Try this: #include <ImageSearch.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{HOME}", "Terminate") $Paused = $Paused send("{pause}") $X = 0 $Y = 0 While 1 Start() WEnd Func Start() $Search = _ImageSearch('1.bmp', 0, $X, $Y, 0) if $Search = 1 Then MouseMove($X, $Y, 10) EndIf EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\User\Desktop\Autoittest\Test.au3" >Exit code: 0 Time: 40.21 Nothing happens when I start the script. Edited July 29, 2014 by qweeztar Link to comment Share on other sites More sharing options...
Developers Jos Posted July 29, 2014 Developers Share Posted July 29, 2014 (edited) Download and install the full SciTE4AutoIt3 installer, open the script with SciTE and run it with F5 from SciTE... what does it tell you? Jos Edited July 29, 2014 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
qweeztar Posted July 30, 2014 Author Share Posted July 30, 2014 (edited) Download and install the full SciTE4AutoIt3 installer, open the script with SciTE and run it with F5 from SciTE... what does it tell you? Jos I got some "error: missing separator character before keyword." from my ImageSearch.au3 The line with the error were the following: Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance) So I changed it to: Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition, ByRef $x, ByRef $y,$tolerance) and I didn't get any more errors, but it still doesn't move the mouse to the picture location. Everything from the box where it shows errors and whatnot. >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\User\Desktop\Autoittest\Test.au3" /UserParams +>13:26:33 Starting AutoIt3Wrapper v.2.2.0.3 SciTE v.3.4.1.0 Keyboard:0000041D OS:WIN_8/ CPU:X64 OS:X64 Environment(Language:0409) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\User\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\User\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\User\Desktop\Autoittest\Test.au3 +>13:26:33 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\User\Desktop\Autoittest\Test.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 25.86 Edited July 30, 2014 by qweeztar Link to comment Share on other sites More sharing options...
Geir1983 Posted July 30, 2014 Share Posted July 30, 2014 Try adding the complete path to the "1.bmp" Link to comment Share on other sites More sharing options...
qweeztar Posted July 30, 2014 Author Share Posted July 30, 2014 (edited) Try adding the complete path to the "1.bmp" Still no difference. >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\User\Desktop\Autoittest\Test.au3" /UserParams +>14:54:00 Starting AutoIt3Wrapper v.2.2.0.3 SciTE v.3.4.1.0 Keyboard:0000041D OS:WIN_8/ CPU:X64 OS:X64 Environment(Language:0409) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\User\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\User\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\User\Desktop\Autoittest\Test.au3 +>14:54:00 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\User\Desktop\Autoittest\Test.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 24.76 #include <ImageSearch.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{HOME}", "Terminate") $Paused = $Paused send("{pause}") $X = 0 $Y = 0 While 1 Start() WEnd Func Start() $Search = _ImageSearch (@ScriptDir & "\1.bmp", 0, $X, $Y, 0) if $Search = 1 Then MouseMove($X, $Y, 10) EndIf EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Edited July 30, 2014 by qweeztar Link to comment Share on other sites More sharing options...
Geir1983 Posted July 30, 2014 Share Posted July 30, 2014 Try to increase the $tolerance of the function, maybe the stored picture is in different quality than what is seen? $Search = _ImageSearch (@ScriptDir & "\1.bmp", 0, $X, $Y, 10) Link to comment Share on other sites More sharing options...
qweeztar Posted July 30, 2014 Author Share Posted July 30, 2014 Try to increase the $tolerance of the function, maybe the stored picture is in different quality than what is seen? $Search = _ImageSearch (@ScriptDir & "\1.bmp", 0, $X, $Y, 10) Still no change. Tried 10, 30 and 100 tolerance. Link to comment Share on other sites More sharing options...
computergroove Posted July 30, 2014 Share Posted July 30, 2014 (edited) Is the picture the same size in its default open size as what is seen on the screen? If you can post the 1.bmp and let me know where it is to be found I will try to fix it. *Edit - Found where you got your code In the comments of that video it says: Replace the dll by one compatible with Windows 7 and/or 64 bit operating systems. Reinstall AutoIt for x68 operating system. I can only test it in Windows 7 x64 and xp x32 on my end. Edited July 30, 2014 by computergroove bbthai77 and jvds 1 1 Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
qweeztar Posted July 30, 2014 Author Share Posted July 30, 2014 https://www.spotify.com/se/signup/?forward_url=%2Fse%2Fget-spotify%2Fgo%2Fpremium%2F%3Ffree_trial%3D1 The picture: https://anonfiles.com/file/e176d0be1870b8893718d9c99996f75b Couldn't upload it to MEGA or Mediafire, neither of the sites loaded for me. Link to comment Share on other sites More sharing options...
computergroove Posted July 30, 2014 Share Posted July 30, 2014 (edited) From the ImageSearch.au3: ; ; Description: Find the position of an image on the desktop ; Syntax: _ImageSearchArea, _ImageSearch ; Parameter(s): ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify ; a desktop region to search ; ;=============================================================================== The reason the script isn't doing anything is that there is nothing for it to do. I added this: Func Start() $Search = _ImageSearch(@DesktopDir & '1.bmp', 0, $X, $Y, 0) if $Search = 0 Then;0 means that the imagesearch hasnt found the image then keep on looking MouseMove($X, $Y, 10) Else MsgBox(0,"Results","Found the Picture!") EndIf EndFunc The problem I am seeing a couple of problems with this script. 1. It checks x and y coords of 0. When it doesn't find the picture at this location then I don't see anywhere where it increases x and/or y pos. When I run the script It starts and immediately stops even with multiple different loop arguments. *Edit - I believe that _SearchImage is handling this. I made my own script based on what the video said and I am also getting nothing in windows 7 x64. *Edit 2 - Tried it in my VM XP with the 32 bit version of the imagesearch.au3 and the program does nothing. *Edit 3 - Im getting an error message in the console when I try to run the script: "C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: if $result[0]="0" then return 0 if $result^ ERROR Line 44 in the imagesearch.au3 is: if $result[0]="0" then return 0 Under _ImageSearchArea which is called when you use add variables to _imageSearch The Au3 appears to be broken. Edited July 30, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
computergroove Posted July 30, 2014 Share Posted July 30, 2014 So I added the info from the ImageSearch.au3 directly into the script and added some lines to try and debug: expandcollapse popup#include <MsgBoxConstants.au3> While 1 Local $X,$Y $Search = _ImageSearch(@DesktopDir & '1.bmp', 0, $X, $Y, 0) MsgBox(0,"Line 6","Return of ImageSearch is :" & $Search) WEnd Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance, $HBMP=0) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage If IsString($findImage) Then $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP) Else $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP) EndIf ; If error exit if $result="0" then ;MsgBox(0,"Line 58 Result","Result = 0") return 0 EndIf ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0],"|") $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif return 1 EndFunc I also added something for the script to do - Msg Box the results of what imagesearch returned, 0 = didnt find the image and 1 = found an image. At least I am getting a return on what imagesearch is finding. I tried a tolerance of 100 and I am still getting a 0 result. I took a screenshot of my desktop and took a small piece of it and cropped it and made sure that there was no white border in paint and saved it as a 24 bit bmp file and saved it to c:. I cannot get imagesearch to return anything except 0. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
TrickyDeath Posted August 19, 2014 Share Posted August 19, 2014 (edited) Stupid question.: Why do not i have this: _ImageSearch in my help file and in SCITE? Do we have a new update again and this one include it? o,O Edit: I found this link, dunno if it is help or not. Edited August 19, 2014 by TrickyDeath Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
Geir1983 Posted August 19, 2014 Share Posted August 19, 2014 _ImageSearch is not an "offical" function, its just a user made function floating around on the forums. I believe its a converted function from autohotkey. Link to comment Share on other sites More sharing options...
TrickyDeath Posted August 19, 2014 Share Posted August 19, 2014 Ahh so that is why i did not seen it in my AutoIT. I gona take a look after it, maybe i can download this addon. Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
Zedna Posted August 19, 2014 Share Posted August 19, 2014 I recommend to use this #AutoIt3Wrapper_UseX64=n to avoid possible problems on 64bit OS. Resources UDF ResourcesEx UDF AutoIt Forum Search 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