dryshirt Posted March 5, 2018 Share Posted March 5, 2018 Hello, this is my first time on the forums. I hope this is the right place to post for assistance. I've come across a script that would help me automate the closing/re-opening of a program based on the state of another program. (if program x is open, program y should be closed, and if program x is closed, program y can be open, where program x is any program from a list. When I use the SciTE-Lite editor to test the code (Tools > Go), the script works as intended. However, when I compile the script to place in my startup programs folder, the script does not work, entering a paused state instead (where the system tray icon flashes between the icon and a red x) I'm not sure why this is happening so I'd appreciate some assistance. The script I'm using is attached (and also appended inline). (turn_rainmeter_off_when_gaming.au3) The script reads from a text file which contains a list of executables which I want the script to monitor (program x from the earlier example). The .txt is placed in the root of the C: drive but you can modify the script to place it anywhere you'd like. Thanks in advance. Script code in-line: #include <Array.au3> #include <File.au3> Local $aGames $file = "C:\Games.exe.txt" _FileReadToArray($file, $aGames) Local $sRunning AdlibRegister("_CheckGame", 1000) ConsoleWrite("_CheckGame() was registered by Adlib" & @CRLF) While 1 Sleep(100) WEnd Func _CheckGame() ; Assign a static variable to hold the number of times games are checked for. Local Static $iGameCount = 0 Local Static $iCount = 0 While 1 For $i = 1 to UBound($aGames) -1 $iGameCount += 1 If $iGameCount > UBound($aGames) Then $iGameCount = 0 $iCount += 1 ConsoleWrite("Checked for a game " & $iCount & " time(s)" & @CRLF) EndIf If ProcessExists($aGames[$i]) Then $sRunning = FileReadLine($file, $i) ConsoleWrite($sRunning & " was launched. Terminating Rainmeter." & @CRLF) ProcessClose("Rainmeter.exe") ConsoleWrite("Rainmeter has been terminated." & @CRLF) ExitLoop 2 EndIf Sleep(100) Next WEnd ConsoleWrite("Running game is " & $sRunning & @CRLF) ConsoleWrite("Checking if Rainmeter can be restarted..." & @CRLF) While 1 If Not ProcessExists($sRunning) Then ConsoleWrite("Starting Rainmeter..." & @CRLF) ShellExecute("C:\Program Files\Rainmeter\Rainmeter.exe") WinWait("Rainmeter") ConsoleWrite("Rainmeter has been restarted." & @CRLF) ExitLoop EndIf WEnd AdlibUnRegister("_CheckGame") AdlibRegister("_CheckGame") EndFunc Exit turn_rainmeter_off_when_gaming.au3 Games.exe.txt Link to comment Share on other sites More sharing options...
Bilgus Posted March 5, 2018 Share Posted March 5, 2018 Generally if you click the icon it goes auto paused If you want to disable this feature Opt("TrayAutoPause", 0) Xandy and dryshirt 2 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2018 Moderators Share Posted March 5, 2018 Hi, This thread was reported as "game-related". As it merely checks whether certain processes are running and does not interact with the listed games in any way, I am happy for it to remain open. dryshirt, Welcome to the AutoIt forum. As I said above, there is nothing wrong with this particular question, but please do read the Forum rules so that you are aware of what is not permitted to be discussed here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dryshirt Posted March 6, 2018 Author Share Posted March 6, 2018 22 hours ago, Bilgus said: Generally if you click the icon it goes auto paused If you want to disable this feature Opt("TrayAutoPause", 0) Thanks, this solved my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now