millertyme44 Posted April 12, 2023 Posted April 12, 2023 I have a seemingly simple problem that I have been scratching my head trying to find a solution with no avail. I have a pretty simple script that just runs a small executable and then issues a series of commands and closes itself, I want this to run daily overnight and if I run the script while actively at the computer it is totally fine and works no problem. The issue I have is when the script tries to run overnight while the screensaver is active it doesnt work until I go on to the computer the next morning and then wake the computer. I have tried running a mouseclick or send keystroke command before the script to "wake" the computer from the screensaver temporarily but that did not work. I found another "solution" to kill the screensaver process (as you can see below) which I tried running beforehand which also is not working, and I am out of ideas so figured I would ask for help. I am open to any potential solution, does not have to be elegant as long as it works. Thanks Quote Local $Title = "iTunes Export" Sleep(5000) func KillScreenSaver() local $szDrive, $szDir, $szFName, $szExt $sspath=RegRead("HKCU\Control Panel\Desktop","SCRNSAVE.EXE") if @error<>0 then return 0 _PathSplit($sspath, $szDrive, $szDir, $szFName, $szExt ) $SCRproc=$szFName & $szExt if ProcessExists($SCRproc) Then processclose($SCRproc) ProcessWaitClose($SCRproc,1) EndIf EndFunc Sleep(30000) Run("C:\playlist exporter\iTunesExportUI.exe") WinWait($Title) WinSetOnTop($Title, "", 1) Opt("WinWaitDelay", 0) While WinExists($Title) WinActivate($Title) Sleep(2000) Send("!n") Sleep(1000) Send("!n") Sleep(1000) Send("{TAB}") Sleep(1000) Send("{TAB}") Sleep(500) Send("c:\playlists") Sleep(1000) Send("{TAB}") Sleep(1000) Send("{SPACE}") Sleep(1000) Send("!f") Sleep(1000) Send("!f") Send("x") WinWaitNotActive($Title) WEnd
Developers Solution Jos Posted April 12, 2023 Developers Solution Posted April 12, 2023 28 minutes ago, millertyme44 said: The issue I have is when the script tries to run overnight while the screensaver is active it doesnt work until I go on to the computer the next morning and then wake the computer. No surprises there. https://www.autoitscript.com/wiki/FAQ#Why_doesn't_my_script_work_on_a_locked_workstation? 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.
millertyme44 Posted April 12, 2023 Author Posted April 12, 2023 3 minutes ago, Jos said: No surprises there. https://www.autoitscript.com/wiki/FAQ#Why_doesn't_my_script_work_on_a_locked_workstation? Is a screensaver and a locked computer the same thing? I have no login or anything set, a normal keystroke or click or mouse movement wakes the computer
millertyme44 Posted April 12, 2023 Author Posted April 12, 2023 Either way I will give that a shot, thank you
Developers Jos Posted April 12, 2023 Developers Posted April 12, 2023 Well, maybe not, but the fact remains that the active application totally covers the screen thus the script interactions are performed against that active Application ( your sceensaver) 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.
millertyme44 Posted April 12, 2023 Author Posted April 12, 2023 Thanks - got it working using controlsend In case anyone stumbles across this and cares the working script is Quote Local $hWND = ("iTunes Export") Sleep(5000) Run("C:\playlist exporter\iTunesExportUI.exe") WinWait($hWND) Sleep(2000) ControlSend($hWND, "", "", "!n") Sleep(1000) ControlSend($hWND, "", "", "!n") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(500) ControlSend($hWND, "", "", "c:\playlists") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(1000) ControlSend($hWND, "", "", "{SPACE}") Sleep(1000) ControlSend($hWND, "", "", "!f") Sleep(1000) ControlSend($hWND, "", "", "!f") ControlSend($hWND, "", "", "x")
TimRude Posted April 16, 2023 Posted April 16, 2023 @millertyme44 Friendly tip: when posting snippets of code, instead of using the Quote button, it's preferable to use the Code button. That way your code looks like this: Local $hWND = ("iTunes Export") Sleep(5000) Run("C:\playlist exporter\iTunesExportUI.exe") WinWait($hWND) Sleep(2000) ControlSend($hWND, "", "", "!n") Sleep(1000) ControlSend($hWND, "", "", "!n") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(500) ControlSend($hWND, "", "", "c:\playlists") Sleep(1000) ControlSend($hWND, "", "", "{TAB}") Sleep(1000) ControlSend($hWND, "", "", "{SPACE}") Sleep(1000) ControlSend($hWND, "", "", "!f") Sleep(1000) ControlSend($hWND, "", "", "!f") ControlSend($hWND, "", "", "x") That'll keep you from getting a scolding.
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