瀏覽代碼

implement proof of work test script

Eren Yilmaz 6 年之前
父節點
當前提交
c81a0e634a
共有 6 個文件被更改,包括 79 次插入2 次删除
  1. 2 1
      .gitignore
  2. 2 1
      config.ini.template
  3. 二進制
      img/0_percent.bmp
  4. 二進制
      img/100_percent.bmp
  5. 二進制
      img/play.bmp
  6. 75 0
      test.ahk

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 .idea
 config.ini
-client
+client
+log.log

+ 2 - 1
config.ini.template

@@ -1,2 +1,3 @@
 [settings]
-ApplicationPath=<path_to_start.exe>
+ApplicationPath=<path_of_start.exe>
+ApplicationPath=<path_of_dir_of_start.exe>

二進制
img/0_percent.bmp


二進制
img/100_percent.bmp


二進制
img/play.bmp


+ 75 - 0
test.ahk

@@ -0,0 +1,75 @@
+
+IniRead, ApplicationPath, %A_WorkingDir%\config.ini, settings, ApplicationPath , ???
+IniRead, ApplicationDir, %A_WorkingDir%\config.ini, settings, ApplicationDir , ???
+
+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
+sleep, 500
+Run, %ApplicationPath%, %ApplicationDir%
+
+FindImg(Image, ByRef X, ByRef Y, MaxTries)
+{
+    global ImgDir
+    WinGetPos, _, _, WindowWidth, WindowHeight
+    loop {
+        Sleep, 1000
+        file := ImgDir "\" Image
+        ImageSearch, X, Y, 0, 0, %WindowWidth%, %WindowHeight%, *5 %file%
+        ifEqual, ErrorLevel, 2
+        {
+            log("Could not conduct the search for " file 0 0 WindowWidth WindowHeight)
+            return False
+        } else ifEqual, ErrorLevel, 1
+        {
+            MaxTries--
+            IfLessOrEqual, MaxTries,  0
+            {
+                log("Could not find " file)
+                return False
+            }
+        } else {
+            return True
+        }
+    }
+}
+
+; Main Program
+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")
+}
+CleanUp()
+
+
+ErrorExit()
+{
+    Process,Close,start.exe
+    Process,Close,patcher.exe
+    log("Exiting with code 1")
+    Exit, 1
+}
+
+CleanUp()
+{
+    Process,Close,start.exe
+    Process,Close,patcher.exe
+    log("Exiting with code 0")
+    Exit, 0
+}