evansullivan Posted March 28, 2019 Posted March 28, 2019 I am trying to write a short script that opens a program, sets focus to that windows, then send a keystroke. It works if I run the script manually but I want it to run via task scheduler. For some reason, it's not setting focus. Here is my entire script, thanks for any help! Local $iPID = Run("C:\Program Files\exacqVision\Client\edvrclient.exe", "", @SW_SHOWMAXIMIZED) Sleep(10000) WinActivate("exacqVision Client") Sleep(2000) Send( "{F11}" )
evansullivan Posted March 28, 2019 Author Posted March 28, 2019 I think setting the focus doesn't work. So when I run it manually it has focus and sends the keystroke.
FrancescoDiMuro Posted March 28, 2019 Posted March 28, 2019 @evansullivan You could use WinWaitActive() instead of the first sleep. By the way, you can't run the script via Task Scheduler? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Nine Posted March 28, 2019 Posted March 28, 2019 Take a look at this thread, it explains how to run a script with Task Scheduler... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
evansullivan Posted March 28, 2019 Author Posted March 28, 2019 (edited) Sorry, I compiled it to an EXE and I am running that. I will try WinWaitActive() Edited March 28, 2019 by evansullivan
evansullivan Posted March 28, 2019 Author Posted March 28, 2019 Still not setting the program window as active so I cannot send the key to the program
evansullivan Posted March 28, 2019 Author Posted March 28, 2019 It's not pretty but I can send an ALT-TAB and it then switches to the window and works just fine. Might have to do as WinActivate("exacqVision Client") is not working
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