TonyTone Posted July 13, 2021 Posted July 13, 2021 (edited) I'm basically using a script to restart a program (because it crashes a lot) . The program it's self is on a server because I would rather not run my computer 24/7. So the script works fine as long as im using it from my laptop connected to the server. If the program crashes when I connect to the server from my phone using RDP, without disconnecting from the session, the program will restart but none of my controlclick functions or mousefunctions will actually do anything, until i personally click the window of the opened program, and then all of a sudden the rest of the script finishes its actions. sidenote: i also looked through the search seemed like others had a similar problem to this but not quite this because their issues were that the script didn't work while the server session was closed, but my session is active. Have tried a couple of different ways one using control click and another using mouse click. Both gives me the same result. This is what I'm running. Global $timeSinceRestart = 0 While 1 if ProcessExists("techstream.exe") Then Sleep(5000) $timeSinceRestart = $timeSinceRestart + 5000 ConsoleWrite("Time since last restart: " & $timeSinceRestart & @CRLF) if $timeSinceRestart >= 900000 Then ProcessClose("techstream.exe") EndIf ElseIf Not ProcessExists("techstream.exe") Then ShellExecute("C:\Users\135admin22\Desktop\techstream.bat") Sleep(7000) $win = WinWait ( "[TITLE:techstream]" ) WinActivate ( $win ) WinWaitActive ( $win ) Sleep(2000) MouseClick("left", 158, 325, 1) ; first MouseClick() sleep(5000) ; delaying second MouseClick() MouseClick("left", 158, 325, 1) ; first MouseClick() sleep(5000) ; delaying second MouseClick() MouseClick("left", 1060, 104, 1) ; first MouseClick() sleep(2000) ; delaying second MouseClick() MouseClick("left", 1060, 104, 1) ; first MouseClick() sleep(2000) ; delaying second MouseClick() MouseClick("left", 1060, 104, 1) ; first MouseClick() $timeSinceRestart = 0 EndIf WEnd or Global $timeSinceRestart = 0 While 1 if ProcessExists("techstream.exe") Then Sleep(5000) $timeSinceRestart = $timeSinceRestart + 5000 ConsoleWrite("Time since last restart: " & $timeSinceRestart & @CRLF) if $timeSinceRestart >= 900000 Then ProcessClose("techstream.exe") EndIf ElseIf Not ProcessExists("techstream.exe") Then ShellExecute("C:\Users\135admin22\Desktop\techstream.bat") Sleep(7000) $win = WinWait ( "[TITLE:techstream]" ) WinActivate ( $win ) WinWaitActive ( $win ) Sleep(1000) ControlClick($win, "", "", "", 1, 40, 300) ; first ControlClick() sleep(5000) ; delaying second ControlClick() ControlClick($win, "", "", "", 1, 40, 300) ; first ControlClick() sleep(5000) ; delaying second ControlClick() ControlClick($win, "", "", "", 1, 944, 71) sleep(2000) ; delaying second ControlClick() ControlClick($win, "", "", "", 1, 944, 71) sleep(2000) ; delaying second ControlClick() ControlClick($win, "", "", "", 1, 944, 71) $timeSinceRestart = 0 EndIf WEnd Edited July 13, 2021 by Jos added codebox
TonyTone Posted July 13, 2021 Author Posted July 13, 2021 Forgot to say Hello, and thanks for any help provided
Developers Solution Jos Posted July 13, 2021 Developers Solution Posted July 13, 2021 The WinWaitActive() will hang indefinitely in that logic, so my might want to put a timeout in there and add an If ... then logic to perform the ControlClicks only on sucess. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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