|
You last visited: Today at 18:20
Advertisement
Repeat Imagesearch
Discussion on Repeat Imagesearch within the AutoIt forum part of the Coders Den category.
03/05/2018, 21:00
|
#1
|
elite*gold: 2
Join Date: May 2009
Posts: 1,024
Received Thanks: 114
|
Repeat Imagesearch
Hello,
im pretty new to coding.
i tried to create a script which should do the following steps:
1. search for image
2. if it appears right click on it
3. if it doesnt appear do some mouse clicks
4. search for image again
5. if it appears right click on it
6 if it doesnt appear do some mouse clicks
and so on and so on
my result is:
without the else part the script is fine and it would right click on the image if it appears, however when i added the else part it wouldnt click on the image anymore if it appeared. (i think i use the else function wrong but let me know what you guys think)
#include <ImageSearch.au3>
HotKeySet("s", "Start")
HotKeySet("e", "_Exit")
Global $y = 0, $x = 0
Func Start()
While 1
sleep (100)
$file = @DesktopDir & '\Coronet.bmp'
local $search = _ImageSearch($file, 1, $x, $y, 0)
if $search = 1 Then
MouseClick("right", $X, $Y)
Sleep (50)
Else
MouseClick ("left", 929, 691)
Sleep (200)
MouseClick ("left", 960, 459)
Sleep (200)
MouseClick ("left", 960, 359)
Sleep (500)
EndIf
Wend
EndFunc
Func _Exit()
Exit
EndFunc
While 1
Sleep(100)
WEnd
|
|
|
03/06/2018, 16:41
|
#2
|
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
|
Try using WaitForImageSearch instead and see if that solves your problem
|
|
|
03/06/2018, 17:34
|
#3
|
elite*gold: 2
Join Date: May 2009
Posts: 1,024
Received Thanks: 114
|
thanks for the help but that didnt work
|
|
|
03/06/2018, 17:37
|
#4
|
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
|
Give it more shade-variation maybe
|
|
|
03/06/2018, 18:33
|
#5
|
elite*gold: 2
Join Date: May 2009
Posts: 1,024
Received Thanks: 114
|
i found the mistake. the picture wasnt good somehow and i had to remake it x.x
|
|
|
09/10/2018, 20:56
|
#6
|
elite*gold: 0
Join Date: Nov 2009
Posts: 105
Received Thanks: 8
|
Quote:
Originally Posted by Hirnverbrannt
Hello,
im pretty new to coding.
i tried to create a script which should do the following steps:
1. search for image
2. if it appears right click on it
3. if it doesnt appear do some mouse clicks
4. search for image again
5. if it appears right click on it
6 if it doesnt appear do some mouse clicks
and so on and so on
my result is:
without the else part the script is fine and it would right click on the image if it appears, however when i added the else part it wouldnt click on the image anymore if it appeared. (i think i use the else function wrong but let me know what you guys think)
#include <ImageSearch.au3>
HotKeySet("s", "Start")
HotKeySet("e", "_Exit")
Global $y = 0, $x = 0
Func Start()
While 1
sleep (100)
$file = @DesktopDir & '\Coronet.bmp'
local $search = _ImageSearch($file, 1, $x, $y, 0)
if $search = 1 Then
MouseClick("right", $X, $Y)
Sleep (50)
Else
MouseClick ("left", 929, 691)
Sleep (200)
MouseClick ("left", 960, 459)
Sleep (200)
MouseClick ("left", 960, 359)
Sleep (500)
EndIf
Wend
EndFunc
Func _Exit()
Exit
EndFunc
While 1
Sleep(100)
WEnd
|
Try to avoide unnessesery orders:
move this line outsed of the While loop, since u do not have to reload the file over and over again.
$file = @DesktopDir & '\Coronet.bmp'
the sleep functions not realy needed between clicks, you can set a click speed in mouseclick("button", $x, $y, number of clicks, speed) "speed [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10."
As Moneypulation said, use higher tolerance in imagesearch. Something like 50 or 100. value 0 mean find the exactly same image as your image stored in the file.
|
|
|
09/26/2018, 07:25
|
#7
|
elite*gold: 0
Join Date: Sep 2012
Posts: 12
Received Thanks: 2
|
Just alternative
#include <ImageSearch.au3>
HotKeySet("s", "Start")
HotKeySet("e", "_Exit")
;Global $y = 0, $x = 0; dont need Global, you will use in same script 
Local $y = 0, $x = 0, $Time_Out = 0
Local $Patch = @DesktopDir & '\Coronet.bmp'
Func Start()
While 1
sleep (100)
Do
Sleep(80)
$Time_Out += 1
Until _ImageSearch($Patch, 1, $x, $y, 0) = 1 Or $Time_Out = 10
If $Time_Out >= 10 Then
MouseClick ("left", 929, 691, 200)
MouseClick ("left", 960, 459, 200)
MouseClick ("left", 960, 359, 500)
Else
MouseClick("right", $X, $Y, 50)
EndIf
Wend
EndFunc
Func _Exit()
Exit()
EndFunc
While 1
Sleep(35)
WEnd
|
|
|
10/28/2018, 19:43
|
#8
|
elite*gold: 0
Join Date: Feb 2011
Posts: 8
Received Thanks: 0
|
#RequireAdmin
#include <ImageSearch.au3>
HotKeySet("s", "Start")
HotKeySet("e", "_Exit")
$y = 0, $x = 0
While 1
sleep (100)
$result = _WaitForImageSearch("Coronet.bmp",15,1,$x1,$y1,0)
if $result=1 Then
MouseClick("right", $X, $Y)
Sleep (50)
Else
MouseClick ("left", 929, 691)
Sleep (200)
MouseClick ("left", 960, 459)
Sleep (200)
MouseClick ("left", 960, 359)
Sleep (500)
EndIf
Wend
Func _Exit()
Exit
EndFunc
While 1
Sleep(100)
WEnd
PROBIER DAS MAL
|
|
|
 |
Similar Threads
|
Quest Repeat.... Help!!..
05/22/2008 - RF Online - 9 Replies
can anyone help me about this hack??!! quest repeat??!!... tnx...
|
The Cursed Shard Rinse and Repeat
07/03/2007 - General Gaming Discussion - 3 Replies
10-1) The Cursed Shard
Rewards: None
Start: Menth Paul, , Mensix Mining Facility, Mustafar
Part 1: What to do? - While traveling around Mustafar you will be attacked on two occasions:
Combat: 3x Tulrus (CL70) area around the Crystal Flats POI marker (was at for me)
Combat: 2x A Smoldering Lava Flea (CL80 Boss) area around The Burning Plains POI marker (was at for me)
|
Hitting much fast / repeat last hit
08/07/2006 - General Gaming Discussion - 2 Replies
All you need is a macro like:
Macroname: hit
And then start it multiple Times ~10.
Now go to a enemy and attack :D
|
Rinse and repeat
06/06/2006 - General Gaming Discussion - 0 Replies
hi i was wondering about the 23k exp repeatable in kash. ive done everthing to get into etyyy and i found the person to talk to. so once im done with the mission do i just click "stop conversing" then accept my thing, or should i stop conversing and exit out of the mssion and then accept the stuff in my journal? im confuzled
|
Repeat Able Sher Kar Caves
01/02/2006 - General Gaming Discussion - 0 Replies
Here how it works
1: Need the Syring to enter the Cave
2: Need a group. Big enought to take down Sher Kar
3: Whole group enters cave with Syringe
4: Person with the Syringe must die and clone and take the 45min lockout
5: Group kills Sher Kar
6: Syringe person immediatly logs off as well as the rest of the group after looting Sher Kar's Corpse
7: Wait 5 mins after logging and log back in. Enter Cave.
|
All times are GMT +1. The time now is 18:21.
|
|