Advertisement
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, 3rdPartyToolsSettingsFile, IdleVolPath, IdleVolUse
- Log("StartGlobalUserFeatures - Starting")
- 3rdPartyToolsSettingsFile := A_ScriptDir . "\Lib\3rdPartyToolsPaths.ini"
- Log("3rdPartyTools - Ini file location " . 3rdPartyToolsSettingsFile, 5)
- 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")
- }
- ; Use this function to define any code you may need to stop or clean up in every module on exit
- StopGlobalUserFeatures(){
- Global IdleVolPath, IdleVolUse
- Log("StopGlobalUserFeatures - Starting")
- 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
Advertisement