How to auto type in other program?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MamboWumbo
Posts: 16
Joined: 15 Jul 2021, 21:08

How to auto type in other program?

Post by MamboWumbo » 24 Jul 2021, 01:17

Hello guys currently I'm stuck, my AHK script won't type my text in another program here is my code

Code: Select all

Run, C:\Users\File.exe,,, GTX01
sleep 5000
ControlSend,, {1},  ahk_pid %GTX01%  ;type 1234 (but wont work, the script stuck there)
ControlSend,, {2},  ahk_pid %GTX01% 
ControlSend,, {3}, ahk_pid %GTX01% 
ControlSend,, {4},  ahk_pid %GTX01% 

Sorry, im very new into programming, i think that spam "ControlSend" wasn't good, and how to make it efficient? thanks!

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: How to auto type in other program?

Post by mikeyww » 24 Jul 2021, 08:09

You can test the following.

Code: Select all

Run, notepad,,, GTX01
WinWaitActive, ahk_pid %GTX01%
ControlSend,, 2
Unfortunately, ControlSend does not work in all windows. You can try ahk_parent as the control name. Tips for games sometimes help.

https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/

I would also display the PID so that you can ensure that a value is present. I would probably first see if you can send to the window without specifying a PID, but perhaps try ahk_exe File.exe.

Of course, if your target window is active, you can use Send instead of ControlSend.

Post Reply

Return to “Ask for Help (v1)”