Running script after windows machine is locked

Get help with using AutoHotkey and its commands and hotkeys
wired137

Running script after windows machine is locked

14 Sep 2018, 11:08

I'm trying to get a script to run while a machine is locked. My script works fine when my machine is not locked. I'm using a standard windows 10 machine. My script is below.

When my machine is locked, the first part of my script executes (launching the 'program')

However, I'm expecting another window to be open while my machine is locked (this is where the ControlSend !f (Alt + F) comes in...then I hit s for the menu I want (called 'Searching), then hit Enter to bring up a new window)

Any suggestions on what could be the issue?

;DllCall("user32.dll\LockWorkStation")
;Sleep 2000
run C:\App.exe
WinWait, ProgramWindowTitle
Sleep 10000
ControlSend ,,!f, ProgramWindowTitle
Sleep 2000
ControlSend ,,s, ProgramWindowTitle
Sleep 2000
ControlSend ,,{Enter}, ProgramWindowTitle

Thanks for any suggestions!
wired137
Posts: 3
Joined: 14 Sep 2018, 11:13

Re: Running script after windows machine is locked

14 Sep 2018, 12:03

I'd like to add that removing WinWait didn't resolve this based on some documentation I found from AutoIT (I know, different software, but figured the logic applied the same)

I also know it can be done and this script below works on my workstation perfectly:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

garry
Posts: 1419
Joined: 22 Dec 2013, 12:50

Re: Running script after windows machine is locked

14 Sep 2018, 14:11

not sure , some ideas
it's possible to run program if you're not admin
to write and save text can use the command 'fileappend'
a german example to send text to notepad and save

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
tank
Posts: 2328
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Louisville KY
Contact:

Re: Running script after windows machine is locked

14 Sep 2018, 16:02

controlsend sends keystrokes which is strictly blocked by windows when locked. you're going to need a more "silent" method of interacting with your application like controlsettext or a COM interface
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
wired137
Posts: 3
Joined: 14 Sep 2018, 11:13

Re: Running script after windows machine is locked

18 Sep 2018, 18:16

Tank, can you provide an example of using ControlSetText with the original code I supplied or point me in the right direction? Can you also explain why the notepad script I pasted works fine when a windows machine is locked?
User avatar
tank
Posts: 2328
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Louisville KY
Contact:

Re: Running script after windows machine is locked

19 Sep 2018, 16:21

your not doing anything in notepad as far as i see looking at your code. Maybe you shoulld just experiment with controlsettext. you dont need an example.
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
wired137
Posts: 3
Joined: 14 Sep 2018, 11:13

Re: Running script after windows machine is locked

Yesterday, 15:07

tank wrote:your not doing anything in notepad as far as i see looking at your code. Maybe you shoulld just experiment with controlsettext. you dont need an example.


I'm not sure what you mean by "your not doing anything" The notepad script I provided locks the computer and then performs the action (create a simple text file) properly while the computer is locked, which is what I am after. I was looking for a reason why this works just fine, even though you said windows security prevents keystrokes being sent

Return to “Ask For Help”

Who is online

Users browsing this forum: shgilad81 and 66 guests