Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Use this function to define any code you want to run in every module on start
- StartGlobalUserFeatures(){
- Global systemName, romName, WinIPACPath, WinIPACProfileDir, changedIPacProfile, 3rdPartyToolsSettingsFile, IdleVolPath, IdleVolUse
- Log("StartGlobalUserFeatures - Starting")
- 3rdPartyToolsSettingsFile := A_ScriptDir . "\Lib\3rdPartyToolsPaths.ini"
- Log("3rdPartyTools - Ini file location " . 3rdPartyToolsSettingsFile, 5)
- Log("WinIPAC - Start IPac System Profile Test")
- WinIPACPath := IniReadCheck(3rdPartyToolsSettingsFile, "WinIPAC", "WinIPACPath",A_ScriptDir . "\WinIPAC\WinIPAC.exe",,1)
- WinIPACProfileDir := IniReadCheck(3rdPartyToolsSettingsFile, "WinIPAC", "WinIPACProfileDir",A_ScriptDir . "\IPACProfiles",,1)
- If !(FileExist(WinIPACPath)) {
- Log("WinIPAC - The file WinIPAC.exe does not exist at " . WinIPACPath . ". Please check your paths!",3)
- } else {
- If !(FileExist(WinIPACProfileDir . "\" . "default.ipc")){
- Log("WinIPAC - IPac required Default Profile not found at " . WinIPACProfileDir . "\" . "default.ipc",5)
- } else {
- Log("WinIPAC - Default profile found: " . WinIPACProfileDir . "\" . "default.ipc",5)
- changedIPacProfile := LoadIPacProfile()
- }
- }
- Log("WinIPAC - Stop IPac System Profile Test")
- Log("IdleVolAdjust - Start IdleVolAdjust Section")
- IdleVolPath := IniReadCheck(3rdPartyToolsSettingsFile, "IdleVolAdjust", "IdleVolPath",A_ScriptDir . "\IdleVolumeAdjuster.exe",,1)
- IdleVolUse := IniReadCheck(3rdPartyToolsSettingsFile, "IdleVolAdjust", "IdleVolUse","No",,1)
- IdleVolSystems := IniReadCheck(3rdPartyToolsSettingsFile, "IdleVolAdjust", "IdleVolSystems","",,1)
- If !(FileExist(IdleVolPath)) {
- Log("IdleVolAdjust - Exe NOT located at " . IdleVolPath . ". Please check your paths", 5)
- IdleVolUse := "No"
- } else {
- IfInString, IdleVolSystems, %systemName%
- {
- Log("IdleVolAdjust - " . systemName . " System found in IdleVolSystems list", 5)
- If (IdleVolUse = "Yes") {
- Log("IdleVolAdjust - Running IdleVolumeAdjuster pause with """ . IdleVolPath . " pause""", 5)
- Run, % IdleVolPath . " pause",,UseErrorLevel,OutputVarPID
- } else If (IdleVolUse = "Kill") {
- Log("IdleVolAdjust - Running IdleVolumeAdjuster Kill with """ . IdleVolPath . " Kill""", 5)
- Log("IdleVolAdjust - Trying to detect if program is running.",5)
- Process, Exist, IdleVolumeAdjuster.exe
- IdleVolPID = %ErrorLevel%
- Log("IdleVolAdjust - IdleVolPID = " . IdleVolPID,5)
- If IdleVolPID = 0
- {
- Log("IdleVolAdjust - Process does not exist. Not stopping the process and it will not be restarted.", 5)
- IdleVolUse := "No"
- } else {
- Log("IdleVolAdjust - Attempting to stop Idle Volume Adjuster with a PID of " . IdleVolPID,5)
- Process, Close, %IdleVolPID%
- CloseIdleVolPID = %ErrorLevel%
- Log("IdleVolAdjust - Close process ErrorLevel - " . CloseIdleVolPID,5)
- If (IdleVolPID = CloseIdleVolPID)
- {
- Log("IdleVolAdjust - Process closed OK.",5)
- } else {
- Log("IdleVolAdjust - Process not closed. Will not restart.",5)
- IdleVolUse := "No"
- }
- }
- }
- } else {
- Log("IdleVolAdjust - " . systemName . " System Not found in IdleVolSystems list :" . IdleVolSystems, 5)
- IdleVolUse := "No"
- }
- }
- Log("IdleVolAdjust - Stop IdleVolAdjust Section")
- Log("StartGlobalUserFeatures - Ending")
- }
- LoadIPacProfile(){
- Global systemName, romName, WinIPACPath, WinIPACProfileDir
- IPacPath1 := WinIPACProfileDir . "\" . systemName . "\" . romName . ".ipc"
- IPacPath2 := WinIPACProfileDir . "\" . systemName . ".ipc"
- Loop, 2 {
- if FileExist(IPacPath%a_index%) {
- Log("WinIPAC - Loading IPAC profile: " . IPacPath%a_index%, 5)
- Run, % WinIPACPath . " " . IPacPath%a_index%,,UseErrorLevel,OutputVarPID
- Process, WaitClose, %OutputVarPID%, 5
- IPacPID = ErrorLevel
- Log("WinIPAC - WinIPAC PID: " . OutputVarPID . " Error Level: " . ErrorLevel, 5)
- ;11:55:54 AM | Title/Class: WinIPAC - Downloading ahk_class ThunderRT6FormDC is now active
- If (ErrorLevel > 0){
- 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.")
- } else {
- Log("WinIPAC - IPAC profile was loaded.",5)
- Return true
- }
- } else {
- Log("WinIPAC - IPac profile " . IPacPath%a_index% . " not found.",5)
- }
- }
- }
- ; Use this function to define any code you may need to stop or clean up in every module on exit
- StopGlobalUserFeatures(){
- Global WinIPACPath, WinIPACProfileDir, changedIPacProfile, IdleVolPath, IdleVolUse
- Log("StopGlobalUserFeatures - Starting")
- Log("WinIPAC - Start IPac Profile Restore")
- If (changedIPacProfile){
- RunWait, % WinIPACPath . " " . WinIPACProfileDir . "\" . "default.ipc",,UseErrorLevel,OutputVarPID
- If (ErrorLevel > 0){
- ScriptError("Your IPac failed to restore. Your default IPac profile was not programmed.")
- } else {
- Log("WinIPAC - Default IPac profile has been restored.",5)
- Return
- }
- } else {
- Log("WinIPAC - Alternative IPac profile not used. No need to restore.")
- }
- Log("WinIPAC - Stop IPac Profile Restore")
- Log("IdleVolAdjust - Start IdleVolAdjust resume section")
- If (IdleVolUse = "Yes") {
- Log("IdleVolAdjust - Running IdleVolumeAdjuster resume with """ . IdleVolPath . " resume""", 5)
- Run, % IdleVolPath . " resume",,UseErrorLevel,OutputVarPID
- } else If (IdleVolUse = "Kill") {
- Log("IdleVolAdjust - Running IdleVolumeAdjuster restart from Kill with """ . IdleVolPath . """", 5)
- Run, % IdleVolPath,,UseErrorLevel,OutputVarPID
- } else {
- Log("IdleVolAdjust - Not adjusting volume. IdleVolUse set to: " . IdleVolUse, 5)
- }
- Log("IdleVolAdjust - Stop IdleVolAdjust resume section")
- Log("StopGlobalUserFeatures - Ending")
- }
Advertisement
Add Comment
Please, Sign In to add comment