Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 05, 2016, 02:36:46 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: AHK Newbie: SendInput to a particular process  (Read 3014 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 245
    • View Profile
    • Mediaguy
    • Donate to Member
AHK Newbie: SendInput to a particular process
« on: May 10, 2010, 09:47:31 AM »
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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,664
    • View Profile
    • Donate to Member
Re: AHK Newbie: SendInput to a particular process
« Reply #1 on: May 10, 2010, 09:58:57 AM »
Code: AutoIt [Select]
  1. 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: 245
    • View Profile
    • Mediaguy
    • Donate to Member
Re: AHK Newbie: SendInput to a particular process
« Reply #2 on: May 10, 2010, 10:26:38 AM »
Thanks, that's the perfect command.

Do you see why this doesn't work?
#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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,664
    • View Profile
    • Donate to Member
Re: AHK Newbie: SendInput to a particular process
« Reply #3 on: May 10, 2010, 10:37:34 AM »
Code: AutoIt [Select]
  1. Run, C:\Windows\System32\notepad.exe, , , notepad1pid
  2. Run, C:\Windows\System32\notepad.exe, , , notepad2pid
  3. Sleep, 500
  4. ControlSend, , Hello Notepad 1, ahk_pid %notepad1pid%
  5. ControlSend, , Hello Notepad 2, ahk_pid %notepad2pid%