test.ahk 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. IniRead, ApplicationPath, %A_WorkingDir%\config.ini, settings, ApplicationPath , ???
  2. IniRead, ApplicationDir, %A_WorkingDir%\config.ini, settings, ApplicationDir , ???
  3. log(Text){
  4. FileAppend, `r`n[%A_DD%.%A_MM%.%A_YYYY% %A_Hour%:%A_Min%:%A_Sec%] %Text%, log.log
  5. }
  6. log("------------------")
  7. log("Starting " ApplicationPath " at " ApplicationDir)
  8. ImgDir = %A_WorkingDir%\img
  9. log(ImgDir)
  10. Process,Close,start.exe
  11. Process,Close,patcher.exe
  12. sleep, 500
  13. Run, %ApplicationPath%, %ApplicationDir%
  14. FindImg(Image, ByRef X, ByRef Y, MaxTries)
  15. {
  16. global ImgDir
  17. loop {
  18. Sleep, 1000
  19. file := ImgDir "\" Image
  20. WinGetPos, WinX, WinY, WindowWidth, WindowHeight, A
  21. ImageSearch, X, Y, 0, 0, %WindowWidth%, %WindowHeight%, *5 %file%
  22. ifEqual, ErrorLevel, 2
  23. {
  24. log("Could not conduct the search for " file)
  25. return False
  26. } else ifEqual, ErrorLevel, 1
  27. {
  28. MaxTries--
  29. IfLessOrEqual, MaxTries, 0
  30. {
  31. log("Could not find " file)
  32. return False
  33. }
  34. } else {
  35. return True
  36. }
  37. }
  38. }
  39. ; Main Program
  40. log("waiting for Kolja-Strohm Games Patcher")
  41. If (not WinWaitActive Kolja-Strohm Games Patcher,,30)
  42. {
  43. log("Kolja-Strohm Games Patcher is not active after 30 seconds")
  44. ErrorExit()
  45. }
  46. Sleep, 1000
  47. log("searching for play button")
  48. if (FindImg("play.bmp", X, Y, 60))
  49. {
  50. log("Patching successful")
  51. } else {
  52. ErrorExit()
  53. }
  54. CleanUp()
  55. ErrorExit()
  56. {
  57. Process,Close,start.exe
  58. Process,Close,patcher.exe
  59. log("Exiting with code 1")
  60. Exit, 1
  61. }
  62. CleanUp()
  63. {
  64. Process,Close,start.exe
  65. Process,Close,patcher.exe
  66. log("Exiting with code 0")
  67. Exit, 0
  68. }