rfancella

User Functions.ahk (IPac)

Mar 15th, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. ; Use this function to define any code you want to run in every module on start
  2. StartGlobalUserFeatures(){
  3. Global systemName, romName, WinIPACPath, WinIPACProfileDir, changedIPacProfile, 3rdPartyToolsSettingsFile
  4. Log("StartGlobalUserFeatures - Starting")
  5. 3rdPartyToolsSettingsFile := A_ScriptDir . "\Lib\3rdPartyToolsPaths.ini"
  6. Log("3rdPartyTools - Ini file location " . 3rdPartyToolsSettingsFile, 5)
  7. Log("WinIPAC - Start IPac System Profile Test")
  8. WinIPACPath := IniReadCheck(3rdPartyToolsSettingsFile, "WinIPAC", "WinIPACPath",A_ScriptDir . "\WinIPAC\WinIPAC.exe",,1)
  9. WinIPACProfileDir := IniReadCheck(3rdPartyToolsSettingsFile, "WinIPAC", "WinIPACProfileDir",A_ScriptDir . "\IPACProfiles",,1)
  10.  
  11. If !(FileExist(WinIPACPath)) {
  12. Log("WinIPAC - The file WinIPAC.exe does not exist at " . WinIPACPath . ". Please check your paths!",3)
  13. } else {
  14. If !(FileExist(WinIPACProfileDir . "\" . "default.ipc")){
  15. Log("WinIPAC - IPac required Default Profile not found at " . WinIPACProfileDir . "\" . "default.ipc",5)
  16. } else {
  17. Log("WinIPAC - Default profile found: " . WinIPACProfileDir . "\" . "default.ipc",5)
  18. changedIPacProfile := LoadIPacProfile()
  19. }
  20. }
  21. Log("WinIPAC - Stop IPac System Profile Test")
  22. Log("StartGlobalUserFeatures - Ending")
  23. }
  24.  
  25.  
  26. LoadIPacProfile(){
  27. Global systemName, romName, WinIPACPath, WinIPACProfileDir
  28. IPacPath1 := WinIPACProfileDir . "\" . systemName . "\" . romName . ".ipc"
  29. IPacPath2 := WinIPACProfileDir . "\" . systemName . ".ipc"
  30. Loop, 2 {
  31. if FileExist(IPacPath%a_index%) {
  32. Log("WinIPAC - Loading IPAC profile: " . IPacPath%a_index%, 5)
  33. Run, % WinIPACPath . " " . IPacPath%a_index%,,UseErrorLevel,OutputVarPID
  34. Process, WaitClose, %OutputVarPID%, 5
  35. IPacPID = ErrorLevel
  36. Log("WinIPAC - WinIPAC PID: " . OutputVarPID . " Error Level: " . ErrorLevel, 5)
  37. ;11:55:54 AM | Title/Class: WinIPAC - Downloading ahk_class ThunderRT6FormDC is now active
  38. If (ErrorLevel > 0){
  39. ScriptError("Your IPac failed to program. Make sure the IPac is connected and try again. You may need to reboot your computer and try again.")
  40. } else {
  41. Log("WinIPAC - IPAC profile was loaded.",5)
  42. Return true
  43. }
  44. } else {
  45. Log("WinIPAC - IPac profile " . IPacPath%a_index% . " not found.",5)
  46. }
  47. }
  48. }
  49.  
  50. ; Use this function to define any code you may need to stop or clean up in every module on exit
  51. StopGlobalUserFeatures(){
  52. Global WinIPACPath, WinIPACProfileDir, changedIPacProfile
  53. Log("StopGlobalUserFeatures - Starting")
  54. Log("WinIPAC - Start IPac Profile Restore")
  55. If (changedIPacProfile){
  56. RunWait, % WinIPACPath . " " . WinIPACProfileDir . "\" . "default.ipc",,UseErrorLevel,OutputVarPID
  57. If (ErrorLevel > 0){
  58. ScriptError("Your IPac failed to restore. Your default IPac profile was not programmed.")
  59. } else {
  60. Log("WinIPAC - Default IPac profile has been restored.",5)
  61. Return
  62. }
  63. } else {
  64. Log("WinIPAC - Alternative IPac profile not used. No need to restore.")
  65. }
  66. Log("WinIPAC - Stop IPac Profile Restore")
  67. Log("StopGlobalUserFeatures - Ending")
  68. }
Advertisement
Add Comment
Please, Sign In to add comment