test.ahk 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. WinGetPos, _, _, WindowWidth, WindowHeight
  18. loop {
  19. Sleep, 1000
  20. file := ImgDir "\" Image
  21. ImageSearch, X, Y, 0, 0, %WindowWidth%, %WindowHeight%, *5 %file%
  22. ifEqual, ErrorLevel, 2
  23. {
  24. log("Could not conduct the search for " file 0 0 WindowWidth WindowHeight)
  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. If (not WinWaitActive Kolja-Strohm Games Patcher,,30)
  41. {
  42. log("Kolja-Strohm Games Patcher is not active after 30 seconds")
  43. ErrorExit()
  44. }
  45. Sleep, 1000
  46. if (FindImg("play.bmp", X, Y, 60))
  47. {
  48. log("Patching successful")
  49. }
  50. CleanUp()
  51. ErrorExit()
  52. {
  53. Process,Close,start.exe
  54. Process,Close,patcher.exe
  55. log("Exiting with code 1")
  56. Exit, 1
  57. }
  58. CleanUp()
  59. {
  60. Process,Close,start.exe
  61. Process,Close,patcher.exe
  62. log("Exiting with code 0")
  63. Exit, 0
  64. }