Bladeren bron

Implement login

Eren Yilmaz 6 jaren geleden
bovenliggende
commit
434809af39
6 gewijzigde bestanden met toevoegingen van 58 en 8 verwijderingen
  1. 1 1
      README.md
  2. 3 1
      config.ini.template
  3. BIN
      img/login_button.bmp
  4. BIN
      img/login_label.bmp
  5. BIN
      img/logo.bmp
  6. 54 6
      test.ahk

+ 1 - 1
README.md

@@ -7,5 +7,5 @@ Work in progress.
 ## Usage:
 
 1. Setup a client program to test. 
-2. Copy `config.ini.template` to `config.ini` and enter the path to the main application inside.
+2. Copy `config.ini.template` to `config.ini` and fill in necessary information.
 3. Run test.ahk with AutoHotKey

+ 3 - 1
config.ini.template

@@ -1,3 +1,5 @@
 [settings]
 ApplicationPath=<path_of_start.exe>
-ApplicationPath=<path_of_dir_of_start.exe>
+ApplicationPath=<path_of_dir_of_start.exe>
+TestAccount=<test account name>
+TestPw=<test account password>

BIN
img/login_button.bmp


BIN
img/login_label.bmp


BIN
img/logo.bmp


+ 54 - 6
test.ahk

@@ -1,6 +1,8 @@
 
 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
@@ -14,30 +16,37 @@ 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
-    loop {
+    Tries = 0
+    loop
+    {
+        Tries++
         Sleep, 1000
         file := ImgDir "\" Image
         WinGetPos, WinX, WinY, WindowWidth, WindowHeight, A
-        ImageSearch, X, Y, 0, 0, %WindowWidth%, %WindowHeight%, *5 %file%
+        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
         {
-            MaxTries--
-            IfLessOrEqual, MaxTries,  0
+            IfGreaterOrEqual, Tries, MaxTries
             {
                 log("Could not find " file)
                 return False
             }
         } else {
+            Tries--
+            log("Found " Image " after " Tries " unsuccessful tries")
             return True
         }
     }
@@ -52,20 +61,58 @@ If (not WinWaitActive Kolja-Strohm Games Patcher,,30)
 }
 
 Sleep, 1000
-log("searching for play button")
 if (FindImg("play.bmp", X, Y, 60))
 {
     log("Patching successful")
 } else {
     ErrorExit()
 }
-CleanUp()
 
+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
 }
@@ -74,6 +121,7 @@ CleanUp()
 {
     Process,Close,start.exe
     Process,Close,patcher.exe
+    Process,Close,game client.exe
     log("Exiting with code 0")
     Exit, 0
 }