Send Keys

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Anyone know how to send keystrokes to another application?
I can set focus to an external app and even pull it out of the task bar if it's been minimized using:

handle.l=FindWindow_(0,"Window Name")
OpenIcon_(handle)
done.l=SetForegroundWindow_(handle)

But now that this window is in focus, how do I send some keystrokes to it like CTRL-R or any key for that matter?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mr.Skunk.

Must go to bed :wink:, so don't have time to try, but perhaps this function will help you.

LRESULT SendMessage(

HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);


Mr Skunk
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

I still am unable to find a way to send keystrokes to external applications. I took a look at what you suggested but am having quite a time interpreting it.
Most other programming languages allow commands to find a window like: FindWindow_(0,"Untitled - Notepad"), open it up, and then use a command similar to:
SendKey("This is my text")
And it will type this into Notepad as if you used the keyboard.
(There are also special codes to send ALT, CTRL, ESC etc.)

Anyone have any ideas??
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
I still am unable to find a way to send keystrokes to external applications
Check out the Beginner thread called 'Send a key to a window?' that I started, the solution is there. :)
Post Reply