How to target a program and simulate f9 key

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
nettechnick
Posts: 1
Joined: 30 Sep 2019, 13:15

How to target a program and simulate f9 key

Post by nettechnick » 30 Sep 2019, 13:41

Hello,

I have a program on Windows Server 2008 R2 that i am trying to have auto login. This is a citrix server and the server is set to restart every morning. The program is in startup to load every time the server restarts. I need to have this program auto login and the only thing I need is for the program to be targeted and the F9 key to be pressed when the program loads after startup but I am new to AHk and unsure how to make this.

The process is called acsuploadw and the file is located C:\ACSshare\ACS\acsuploadw.exe

Thank you guys in advance for any help with this.

lexikos
Posts: 9665
Joined: 30 Sep 2013, 04:07
Contact:

Re: How to target a program and simulate f9 key

Post by lexikos » 04 Oct 2019, 18:25

You need to:
  • Wait for the window to appear (or wait for it to become active if it activates itself).
  • Activate it (if it doesn't activate itself).
  • Send F9.

Code: Select all

WinWait "ahk_exe acsuploadw.exe"  ; If it opens multiple windows, narrow it down by including the window title before ahk_exe.
WinActivate
Send "{F9}"
This script can be placed in startup like any other program. If the window is already visible, it will be activated almost immediately and F9 will be sent.

It might also be possible (and potentially more reliable) to send F9 directly, without requiring activation.

Code: Select all

WinWait "ahk_exe acsuploadw.exe"
ControlSend "{F9}"
This depends on how (or on which control) the program accepts the F9 key.

If F9 is to activate a menu item and the window uses a standard type of menu, you can use MenuSelect instead.

(This code is all for AutoHotkey v2-alpha, as you have posted in the v2 subforum.)

Post Reply

Return to “Ask for Help (v2)”