|
You last visited: Today at 19:23
Advertisement
Threading - ImageSearch
Discussion on Threading - ImageSearch within the AutoIt forum part of the Coders Den category.
12/20/2015, 15:16
|
#1
|
elite*gold: 0
Join Date: Jan 2010
Posts: 507
Received Thanks: 203
|
Threading - ImageSearch
Hey!!
Ich wollte mal fragen wie ich Folgendes Script so optimieren kann, dass das Script normal
weiter läuft und nicht durch die Sleep Funktion angehalten wird..
Code:
Func Lot()
Dim $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4
$result = _Imagesearch(@ScriptDir & "/img/lot.bmp", 1, $x1, $y1, 10)
If $result = 1 Then
Dim $MouseNow = MouseGetPos()
MouseClick("Left", $x1, $y1, 5)
MouseMove($MouseNow[0], $MouseNow[1])
Sleep(200)
EndIf
$result1 = _Imagesearch(@ScriptDir & "/img/Free.bmp", 1, $x2, $y2, 10)
If $result1 = 1 Then
Dim $MouseNow1 = MouseGetPos()
MouseClick("Left", $x2, $y2, 5)
MouseMove($MouseNow1[0], $MouseNow1[1])
Sleep(200)
EndIf
If PixelGetColor(1158, 42) = Dec("563D2C") Then
MouseClick("Left", 1090, 264, 2)
Sleep(600)
MouseClick("Left", 1151, 265, 2)
Sleep(500)
EndIf
EndFunc
Ich komme mit der Funktion von dem Timer nicht so ganz klar..
Ich hoffe ihr wisst was ich meine und vielen dank schonmal.
|
|
|
12/20/2015, 15:28
|
#2
|
elite*gold: 0
Join Date: Mar 2010
Posts: 360
Received Thanks: 132
|
Die Sleeps entfernen ? o.O
Richtiges Threading gibt es in Autoit nicht und adlib ist hier auch keine Option.
Wenn du eine Aktion verzögern und das Script dabei nicht blockieren willst, solltest du einen Timer verwenden.
Pseudo Code
Code:
while
if(Bedingung) {
Aktion 1
Starte Timer1
}
if(Timer1){
if timeDiff(Timer1) > Zeitschranke {
doAction1
delete Timer1
}
}
Wend
|
|
|
12/20/2015, 16:08
|
#3
|
elite*gold: 0
Join Date: Dec 2013
Posts: 47
Received Thanks: 9
|
wiederholt die suche bis sie nicht mehr wahr ist
Quote:
Do
$result = _Imagesearch(@ScriptDir & "/img/lot.bmp", 1, $x1, $y1, 10)
If $result = 1 Then
Dim $MouseNow = MouseGetPos()
MouseClick("Left", $x1, $y1, 5)
MouseMove($MouseNow[0], $MouseNow[1])
EndIf
Until $result = 0
|
|
|
|
12/20/2015, 16:41
|
#4
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 166
|
Try with timer diff that should be enough
Code:
Global $timer1,$timer2,$ready1,$ready2
$ready1 = 1
$ready2 = 1
Func Lot()
Dim $x1, $y1
$result = _Imagesearch(@ScriptDir & "/img/lot.bmp", 1, $x1, $y1, 10)
If $result = 1 And $ready1 Then
Dim $MouseNow = MouseGetPos()
MouseClick("Left", $x1, $y1, 5)
MouseMove($MouseNow[0], $MouseNow[1])
$timer1 = TimerInit()
$ready1 = 0
EndIf
$result = _Imagesearch(@ScriptDir & "/img/Free.bmp", 1, $x2, $y2, 10)
If $result = 1 and $ready2 Then
Dim $MouseNow1 = MouseGetPos()
MouseClick("Left", $x2, $y2, 5)
MouseMove($MouseNow1[0], $MouseNow1[1])
$timer2 = TimerInit()
$ready2 = 0
EndIf
If TimerDiff($timer1) >= 200 Then ;200 ms
$timer1 = Null
$ready1 = 1
EndIf
If TimerDiff($timer2) >= 200 Then ;200 ms
$timer2 = Null
$ready2 = 1
EndIf
If PixelGetColor(1158, 42) = Dec("563D2C") and $ready4 Then
MouseClick("Left", 1090, 264, 2)
Sleep(600)
MouseClick("Left", 1151, 265, 2)
Sleep(500)
EndIf
EndFunc
|
|
|
12/20/2015, 23:37
|
#5
|
elite*gold: 0
Join Date: Mar 2010
Posts: 360
Received Thanks: 132
|
Quote:
Originally Posted by elmarcia
Try with timer diff that should be enough
|
wow.
Your "Example" is really bad. Don't post codes if you don't know how to work with autoit. There are so many errors and all in all it's just wrong and not working.
|
|
|
|
Similar Threads
|
C++ Threading
03/01/2013 - C/C++ - 3 Replies
Ich habe da mal eine frage zu Threading in C++
Wie kann ich eine Thread Array starten?
ich weiß das ich in C# es z.B. so machen kann:)
Thread myThread;
myThread= new myThread;
|
Threading
02/22/2013 - Nostale - 3 Replies
Hi!I have a question for what i need multithreading i developing game server.Soo i know that i need this for connection.
|
C# threading mit Invoke nur wie =)
08/28/2012 - .NET Languages - 10 Replies
hallo com, ich habe vor mein tool was ich geschriben habe in mehreren threads laufen zu lassen.
doch dabei stosse ich auf ein problem, ich habe eine if anweisung mit einer checkbox doch dies muss ich über invoke machen. doch ich bekomme es nicht hin.
habt ihr mir einen Vorschlag?
if (checkBox3.Checked == true)
Fehler:
Fehler 1 Für das nicht statische Feld, die Methode oder die Eigenschaft "WindowsFormsApplication1.Form1.checkBox3&quo t; ist ein Objektverweis...
|
C++ Threading
03/24/2012 - CO2 Programming - 13 Replies
Anybody got some good threading tutorials in c++?
#Edit
Using boost would be fine?
|
Threading
11/18/2011 - CO2 Private Server - 10 Replies
What should I do?
A thread for every map that's used by players, a global thread for all players or a single thread for every player.
|
All times are GMT +2. The time now is 19:23.
|
|