Sign in to follow this  
Followers 0
HaNdLoRdz

Help with my code (looping problem)

5 posts in this topic

#1 ·  Posted (edited)

#include <ImageSearch.au3>
#include <MsgBoxConstants.au3>


HotKeySet("p", "pause")
HotKeySet("o", "CheckImage")
global $y = 0, $x = 0
$apos = MouseGetPos()


;;;; koordinat kalah di posisi DOWN = X: 820, Y:506
;;;; koordinat kalah di posisi up = X: 137, Y:506

While 1
sleep (50)
Checkimage()

WEnd
Func CheckImage()
   sleep (100)
   menang()
   sleep(100)
   kalah()
   sleep(100)
   error()
EndFunc

Func Menang()
Local $search = _ImageSearch('Binary.bmp', 0, $x, $y, 0)
;local $searchPlay = _ImageSearch('PlayAgain.bmp', 0, $x, $y, 0)
If $search = 1 then;AND $searchPlay = 1 then
   ;If $searchPlay = 1 then
   MouseMove(862,485,10)
   sleep(100)
   mouseclick("left",862,485,1)
   sleep(100)
   pindah()
   sleep(100)
   resetstake()
   sleep(2000)
   MouseMove(800,320,10)
   sleep(100)
   mouseclick("left",800,320,1)
   Sleep(100)
   ;MsgBox(0,"status","menang")
EndIf
;Else
;   kalah()
;EndIf
EndFunc


Func Kalah()
   Local $search = _ImageSearch('kalah.bmp', 0, $x, $y, 0)
   ;Local $searchPlay = _ImageSearch('PlayAgain.bmp', 0, $x, $y, 0)
If $search = 1 then ;AND $searchPlay = 1 then
   MouseMove(862,485,10)
   sleep(100)
   mouseclick("left",862,485,1)
   sleep(100)
   MouseMove(853,233,10)
   sleep(50)
   mouseclick("left",853,233,2)
   sleep(100)
   MouseMove(800,320,10)
   sleep(100)
   mouseclick("left",800,320,1)
   sleep(1000)

EndIf
EndFunc

Func pause()
   sleep(100000000000)
endfunc

Func resetstake()
Sleep(100)
MouseMove(820,234,10);
Sleep(100)
mouseclick("left",820,234,1)
Sleep(500)
MouseMove(819,265,10)
Sleep(500)
mouseclick("left",819,265,3)
sleep(100)
MouseMove(770,258,10)
Sleep(200)
mouseclick("left",770,258,1)
Sleep(100)
endfunc



func pindah()
   sleep(100)
   MouseMove(150,200,10);;;;;;buat klik ditempat kosong
   sleep(500)
   mouseclick("left",150,200,3)
   sleep(500)
   ;WinActivate("Mozilla") ;
   sleep(100)
   Send("{CTRLDOWN}")
   sleep(100)
   send("{TAB}")
   sleep (100)
   Send("{CTRLUP}")
   sleep(100)
endfunc

Func restart()
   sleep(6000)
   MouseMove(105,16,10);klik tab 1 firefox
   sleep(100)
   mouseclick("left",105,16,1)
   sleep(100)
   MouseMove(126,154,10)
   sleep(1000)
   mouseclick("left",126,154,1)
   sleep (1000)
   send ("{F5}")
   sleep(10000)
   mousemove(943,452,10)
   sleep(100)
   MouseClick("left",943,452,1)
   sleep(100)
   send("{DOWN}")
   sleep(100)
   send("{ENTER}")
   sleep(100)
   mousemove(820,424,10)
   sleep(100)
   MouseClick("left",820,424,1)
   sleep(100)
   mousemove(819,462,10)
   sleep(100)
   MouseClick("left",819,462,1)
   sleep(100)
   mousemove(763,444,10)
   sleep(100)
   MouseClick("left",763,444,1)
   sleep(100)
   mousemove(758,506,10)
   sleep(100)
   MouseClick("left",758,506,1)
   sleep(100)
   send("{UP}")
   sleep(100)
   send("{ENTER}")
   sleep(1000)
   MouseMove(326,16,10)
   sleep(100)
   mouseclick("left",326,16,1)
   sleep(100)
   MouseMove(126,154,10)
   sleep(1000)
   mouseclick("left",126,154,1);
   sleep (1000)
   send ("{F5}")
   sleep(10000)
   mousemove(943,452,10);
   sleep(100)
   MouseClick("left",943,452,1)
   sleep(100)
   send("{DOWN}")
   sleep(100)
   send("{ENTER}");
   sleep(100)
   mousemove(820,424,10);
   sleep(100)
   MouseClick("left",820,424,1)
   sleep(100)
   mousemove(819,462,10);
   sleep(100)
   MouseClick("left",819,462,1)
   sleep(100)
   mousemove(763,444,10);
   sleep(100)
   MouseClick("left",763,444,1)
   sleep(100)
   mousemove(758,506,10);
   sleep(100)
   MouseClick("left",758,506,1)
   sleep(100)
   send("{DOWN}")
   sleep(100)
   send("{ENTER}");
   sleep(100)
   MouseMove(797,506,10)
   sleep(100)
   mouseclick("left",797,506,1)
   Sleep(100)
EndFunc

Func error()
Local $search = _ImageSearch('error.bmp', 0, $x, $y, 0)
If $search = 1 then
   restart()
EndIf

EndFunc

can anyone help me with my unfinished code??

i just want when the condition for Func Kalah() = true for the first time then i will send "2", after that if that condition still "TRUE" then it will send "5", and if still "TRUE" it will send "10",etc

 

how can i got the correct code for that??

oh...n one more, beside its running Checkimage() over n over, at the same time i want to Pause after 10 minutes of running n at the same time it will running another Function and then after that it will go to the top code again.

can someone help me??

sorry im new comer n sorry for my bad english

regards,

Edited by HaNdLoRdz

Share this post


Link to post
Share on other sites



HaNdLoRdz,

I see the words "Win" & "Lose" in that code - what are you automating? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

hi m23,

i want to automate some game in my computer (flash base)

could u help me ?

hmmm...just confuse how can i send "2" and "5" and "1" cos its like shortcut n it cant be replace with another key.

thx

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Looks like you missed to read the forum rules.

Game automation isn't allowed here.

Edit: Looks like I missed that Melba already asked a similar question. A smartphone screen is way too small :)

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

HaNdLoRdz,

 

i want to automate some game

I was afraid of that - which is why I asked. :(

water is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0