DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: AHK Newbie: SendInput to a particular process  (Read 6,874 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
AHK Newbie: SendInput to a particular process
« on: May 10, 2010, 02:47 PM »
Hi all,
I've just written a very simple AHK script to load up VNC and then log into a PC, open IE, go to a website and login. The trouble is that if I click off the window it all breaks.

Is there a way of sending keys to a particular process (and if so how to find the process)? The process is started by AHK in the script.

Thanks

Graham
Learning C# - Graham Robinson

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: AHK Newbie: SendInput to a particular process
« Reply #1 on: May 10, 2010, 02:58 PM »
Code: (AutoIt)
Run, c:\path\to\my.exe, , , myPID ; myPID will have the started process' ID.

You can then try the ControlSend command for sending keys to a particular process.  Controlling a web browser in this manner can be an exercise in frustration, however.

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
Re: AHK Newbie: SendInput to a particular process
« Reply #2 on: May 10, 2010, 03:26 PM »
Thanks, that's the perfect command.

Do you see why this doesn't work?
Code
#2::
Run, C:\Windows\System32\notepad.exe, , , notepad1pid
Run, C:\Windows\System32\notepad.exe, , , notepad2pid
Sleep, 500
ControlSend, notepad1pid, Hello Notepad 1
ControlSend, notepad2pid, Hello Notepad 2
return
Learning C# - Graham Robinson

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: AHK Newbie: SendInput to a particular process
« Reply #3 on: May 10, 2010, 03:37 PM »
Code: (AutoIt)
Run, C:\Windows\System32\notepad.exe, , , notepad1pid
Run, C:\Windows\System32\notepad.exe, , , notepad2pid
Sleep, 500
ControlSend, , Hello Notepad 1, ahk_pid %notepad1pid%
ControlSend, , Hello Notepad 2, ahk_pid %notepad2pid%

Original address: https://www.donationcoder.com/forum/index.php?topic=22688.0