123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- IniRead, ApplicationPath, %A_WorkingDir%\config.ini, settings, ApplicationPath , ???
- IniRead, ApplicationDir, %A_WorkingDir%\config.ini, settings, ApplicationDir , ???
- IniRead, TestAccount, %A_WorkingDir%\config.ini, settings, TestAccount , ???
- IniRead, TestPw, %A_WorkingDir%\config.ini, settings, TestPw , ???
- log(Text){
- FileAppend, `r`n[%A_DD%.%A_MM%.%A_YYYY% %A_Hour%:%A_Min%:%A_Sec%] %Text%, log.log
- }
- log("------------------")
- log("Starting " ApplicationPath " at " ApplicationDir)
- ImgDir = %A_WorkingDir%\img
- log(ImgDir)
- Process,Close,start.exe
- Process,Close,patcher.exe
- Process,Close,game client.exe
- sleep, 500
- Run, %ApplicationPath%, %ApplicationDir%
- FindImg(Image, ByRef X, ByRef Y, MaxTries)
- {
- log("searching for "Image)
- global ImgDir
- Tries = 0
- loop
- {
- Tries++
- Sleep, 1000
- file := ImgDir "\" Image
- WinGetPos, WinX, WinY, WindowWidth, WindowHeight, A
- log("search")
- ImageSearch, X, Y, 0, 0, %WindowWidth%, %WindowHeight%, *10 %file%
- ifEqual, ErrorLevel, 2
- {
- log("Could not conduct the search for " file)
- return False
- } else ifEqual, ErrorLevel, 1
- {
- IfGreaterOrEqual, Tries, MaxTries
- {
- log("Could not find " file)
- return False
- }
- } else {
- Tries--
- log("Found " Image " after " Tries " unsuccessful tries")
- return True
- }
- }
- }
- ; Main Program
- log("waiting for Kolja-Strohm Games Patcher")
- If (not WinWaitActive Kolja-Strohm Games Patcher,,30)
- {
- log("Kolja-Strohm Games Patcher is not active after 30 seconds")
- ErrorExit()
- }
- Sleep, 1000
- if (FindImg("play.bmp", X, Y, 60))
- {
- log("Patching successful")
- } else {
- ErrorExit()
- }
- log("clicking at " X ", " Y)
- click,%X%,%Y%
- If (not WinWaitActive Game Client,,10)
- {
- log("Game Client is not active after 30 seconds")
- ErrorExit()
- } else
- {
- log("Game Client active")
- }
- if (not FindImg("login_label.bmp", X, Y, 10))
- {
- ErrorExit()
- }
- log("logging in as " TestAccount)
- Send, %TestAccount%
- Send, {Tab}
- Send, %TestPw%
- if (not FindImg("login_button.bmp", X, Y, 3))
- {
- ErrorExit()
- }
- X += 53
- Y += 14
- MouseMove, %X%, %Y%
- Click, down
- Sleep, 500
- Click, up
- if (not FindImg("logo.bmp", X, Y, 3))
- {
- ErrorExit()
- }
- CleanUp()
- ErrorExit()
- {
- Process,Close,start.exe
- Process,Close,patcher.exe
- Process,Close,game client.exe
- log("Exiting with code 1")
- Exit, 1
- }
- CleanUp()
- {
- Process,Close,start.exe
- Process,Close,patcher.exe
- Process,Close,game client.exe
- log("Exiting with code 0")
- Exit, 0
- }
|