Click here to Skip to main content
Click here to Skip to main content

SendKeys in C++

By , 14 Jun 2004
 

Introduction

One day I needed to send keys to another application in order to automate a task from my C++ program, but after some research, I found no easy way to do that in C++ and all what was found is reference to VB's or C#'s SendKeys. However, one of the search results returned sndkeys32.pas which is a Delphi code version of the SendKeys() written by Ken Henderson back in 1995.

Since I know Delphi and wanted this same functionality in C++, I decided to port and enhance the code to make it fit my needs. The remainder of the article will explain the concept of sending keys in Win32 and will show you how to use the code in order to send keys in just two lines of code!

Hope you find this article useful.

Key sending concept in Win32

The core functionality of sending keys in CSendKeys revolves around the usage of the keybd_event() Win32 API function.

The keybd_event() produces a keystroke, however the keyboard driver's interrupt handles the calls to this function, which means we can send almost any key combination with less limitations.

In brief, it allows you to send a virtual key, defined in winuser.h as VK_XXX, and a flag which denotes a KeyDown, KeyUp or state to tell if the VKey is an extended key or not.

Normal characters are translated into virtual keys using the VkKeyScan() which takes a CHAR and returns a WORD denoting a VK.

When you send a key, it will be depressed until you send it again with the KEYEVENTF_KEYUP flag.

Here is a small snippet that allows you to send the ALT-TAB sequence:

  // press DOWN "Alt-Tab"
  keybd_event(VK_MENU, 0, 0, 0);
  keybd_event(VK_TAB, 0, 0, 0);

  ::Sleep(1000);

  // stop pressing "Alt-Tab"
  keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
  keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);

As you see, in order to send this simple keys combination, 4 lines of coded were needed. Here is where CSendKeys comes to simplify this task.

How to use the code

In short, the code can be used as:
#include "SendKeys.h"
.
.
.
CSendKeys sk;
// Send "Hello world!"
sk.SendKeys("Hello world!");
.
.
.
.
.
.
// Run notepad
sk.SendKeys("{DELAY=50}@rnotepad{ENTER}");

<P>
</P>

CSendKeys is designed in a way to maintain certain compatibility with C#'s SendKeys while also adding more functionality. So if you used C#'s SendKeys.Send() or VB's before then using CSendKeys becomes easier.

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter 'a', pass in the string "a" to the method. Naturally to represent a string of characters just pass them in order as "hello".

If you want to send modifier keys such as the SHIFT, ALT, CONTROL or WINKEY keys in addition to normal keys, you might want to use any of the characters defined in Table 3.

For example, if you want to send "A" you usually press Shift+A, which is equivalent to sending these key strokes: "+a" , similarly to send the "~" you would press Shift+` which is equivalent to key strokes "+`" or simply "{TILDE}" (Table 1.b).

All characters in Table 3 are reserved and have special meaning in addition to the left/right parenthesis/braces.

The parenthesis are used to associate a given modifier or modifiers with a group of characters, for example to send the "HELLO", you would describe as "+(hello)" which informs CSendKeys to depress the SHIFT key while sending the following keys group. Whereas the braces are used to enclose any of the keys displayed in Table 1 and 2.

The sent keys are sent to no specific application, instead they are just pressed and whatever application has the keyboard input will take the keys.

In order to send the keys to a specific window/application please use either of the methods:

// 1. activate an application using its handle
sk.AppActivate(hWnd);

// 2. activate an application given its window title
sk.AppActivate("Title");

/// 3. activate an application given either or both of its window title/class
sk.AppActivate(NULL, "TheClass"); // NULL means this criteria is not avail

// 4. via SendKeys method
sk.SendKeys("{appactivate Notepad}hello");

The following table is a slightly modified version of the MSDN/SendKeys help:

Key Code
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC} (reserved for future use)
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLL}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Keypad add {ADD}
Keypad subtract {SUBTRACT}
Keypad multiply {MULTIPLY}
Keypad divide {DIVIDE}
(table 1.a)

The following are my additions:

Key Code
+ {PLUS}
@ {AT}
APPS {APPS}
^ {CARET}
~ {TILDE}
{ } {LEFTBRACE} {RIGHTBRACE}
( ) {LEFTPAREN} {RIGHTPAREN}
Left/Right WINKEY {LWIN} {RWIN}
WINKEY {WIN} equivalent to {LWIN}
(table 1.b)

In addition to this, I have added some special keys that act like commands:

Command Syntax Action
{VKEY X} Sends the VKEY of value X.

Very useful if you don't want to recompile CSendKeys and add new Vkey to the hardcoded special keys table.

For example, {VKEY 13} is equivalent to VK_RETURN.

{BEEP X Y}} Beeps with a frequency of X and a duration of Y milliseconds.
{DELAY X} Delays sending the next key of X milliseconds. After the delaying the following key, the subsequent keys will not be further delayed unless there is a default delay value (see DELAY=X).

Example: {DELAY 1000} <-- delays subsequent key stroke for 1 second.

{DELAY=X} Sets the default delay value to X milliseconds. This will cause every key to be delayed X ms.

If a value is already set and you specify {DELAY Y} you will have your following key delay Y ms but the subsequent keys will be delayed X ms.

Example: {DELAY=1000} <-- all subsequent keys will be delayed for 1 second.

{APPACTIVATE WindowTitle} Activates an application using is WindowTitle.

Very useful if you want to send different keys to different applications.

(table 2)

Key Code
WINKEY @
SHIFT +
CTRL ^
ALT %
(table 3)

Here are some examples:

Keystrokes Description
{DELAY=50}@rnotepad~hello world%ha
  1. set delay after each character to 50 ms
  2. WINKEY+R to invoke the run dialog

  3. type "notepad" and press ENTER
  4. Type "hello world"
  5. Invoke Alt+H then press "A" to invoke the about dialog of notepad
{delay=100}{appactivate Calculator}{ESC}5*7~{beep 1000 500}^c{appactivate Notepad}^a{DEL}Result of 5*7 is: ^v Given that "Calc.exe" and "Notepad.exe" are running:
  1. set delay to 100 ms
  2. activate calculatr
  3. press ESC to clear previous result
  4. type in 5*7 then press ENTER
  5. beep for 500ms with a frequency of 1000
  6. press CTRL+C to copy result
  7. activate notepad
  8. press CTRL+A then DEL in notepad to delete previously written text
  9. type in a phrase then press CTRL+V to paste the copied result
{DELAY=500}{NUMLOCK}{CAPSLOCK}{SCROLL}{SCROLL}{CAPSLOCK}{NUMLOCK}
  1. Press NUM,CAPS,SCROll lock in order
  2. Turn them off in reverse order
{DELAY=500}% {DOWN 5}
  1. press ALT+SPACE
  2. press DOWN key 5 times

For more examples see the accompanying sample code.

  • 04/19/2004
    • Initial version development
  • 04/21/2004
    • Added number of times specifier to special keys
    • Added {BEEP X Y}
    • Added {APPACTIVATE WindowTitle}
    • Added CarryDelay() and now delay works properly with all keys
    • Added SetDelay() method
    • Fixed code in AppActivate that allowed to pass both NULL windowTitle/windowClass
  • 05/21/2004
    • Fixed a bug in StringToVKey() that caused the search for RIGHTPAREN to be matched as RIGHT
    • Adjusted code so it compiles w/ VC6
  • 05/24/2004
    • Added Unicode support

Reference

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Elias Bachaalany
Web Developer
United States United States
Member
Elias (aka lallousx86, @0xeb) has always been interested in the making of things and their inner workings.
 
His computer interests include system programming, reverse engineering, writing libraries, tutorials and articles.
 
In his free time, and apart from researching, his favorite reading topics include: dreams, metaphysics, philosophy, psychology and any other human/mystical science.
 
Former employee of Hex-Rays (the creators of IDA Pro), was responsible about many debugger plugins, IDAPython project ownership and what not.
 
Elias currently works at Microsoft as a software security engineer.
 
More articles and blog posts can be found here:
 
- http://lallousx86.wordpress.com/
- http://0xeb.wordpress.com/
- http://www.hexblog.com/?author=3

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionI need to know how to open and debug the code in VS2010memberAhmedn14 Dec '11 - 3:46 
I tried to open the solution in VS2010
but I got an error when I try to run the solution
 
"Unable to start program 'D:\SendKeys\.\Debug\\SendKeysSample.exe'
The system cannot find the file specified"
GeneralIs there any way to use this code with Qt? (error: cannot convert 'const char*' to 'const TCHAR*' )memberghtofighi24 May '11 - 19:46 
I tried to use this code in Qt, but it has this main problem:
 
error: cannot convert 'const char*' to 'const TCHAR*'
GeneralBugs in CSendKeys::AppActivate(LPCTSTR WindowTitle, LPCTSTR WindowClass)membergregko314618 May '11 - 4:48 
Thank you for providing this code, it is very useful! However, I found two problems with AppActivate() by window title and class name:
 
First, this line does not work correctly when compiling for Unicode, leaving garbage in "titleclass" and causing grief later in the search:
 
memset(titleclass, 0, l1 + l2 + 5);
 
Should be modified to:
 
memset(titleclass, 0, (l1 + l2 + 5)*sizeof(TCHAR));
 
Second, the code in CSendKeys::enumwindowsProc() seems to match any window of the given class name (if wclass is not NULL), regardless of window title provided. The code as provided in this article is:
  BOOL bMatch(FALSE);
 
  if (wclass)
  {
    TCHAR szClass[300];
    if (::GetClassName(hwnd, szClass, _countof(szClass)))
      bMatch |= (_tcsstr(szClass, wclass) != 0);
  } 
 
  if (wtitle)
  {
    TCHAR szTitle[300];
    if (::GetWindowText(hwnd, szTitle, _countof(szTitle)))
      bMatch |= (_tcsstr(szTitle, wtitle) != 0);
  }
 
To make it work correctly I modified it to:
  BOOL bMatch(FALSE);
 
  // Modified by Greg to match class AND title, if both given
  if (wclass)
  {
    TCHAR szClass[300];
    if (::GetClassName(hwnd, szClass, _countof(szClass)))
      bMatch = (_tcsstr(szClass, wclass) != 0);
  } 
 
  if (wtitle && (!wclass || bMatch))
  {
    TCHAR szTitle[300];
    bMatch = FALSE; // needed if we can't get window text...
    if (::GetWindowText(hwnd, szTitle, _countof(szTitle)))
      bMatch = (_tcsstr(szTitle, wtitle) != 0);
  }
 
Greg
Questionsend ?%$# key eventmemberMember 76917712 Mar '11 - 23:25 
Hi,
 
Can you please tell how it can be achived to send above mentioned keys. I have checked your code and tried to send % key but it didn't worked for me. i am trying to achieve the same in c#.
 
Thanks in advance
Anant
AnswerRe: send ?%$# key eventmemberElias Bachaalany3 Mar '11 - 0:04 
Hello,
 
It is explained in the article.
 
For example to send "?" , it is Shift+"/". The shift is represented (as per Table 3) by a "+", thus: "?" = "+/"
GeneralError [modified]memberZyx862 Dec '10 - 23:09 
Hi, I have inserted SendKeys.h in my project but I have an error in my code relative to SendKeys: the type "const char" is incompatible with "LPTCTSTR"
 
#include "stdafx.h"
#include "winuser.h"
#include "SendKeys.h"

 

int main( int argc, char** argv ) {
	IplImage* img;
	char key = getchar();
	CSendKeys sk;
 
	
 
	if(key=='q'){
	
		sk.SendKeys("Hello world!");
	}	
}

modified on Friday, December 3, 2010 5:15 AM

GeneralCannot send ^a to Firefoxmemberkmpham20 Jul '10 - 17:00 
Hi,
 
Thanks for your work... really.
 
I try to send a CTRL+A to Firefox, but it doesn't work, it's fine when I send regular characters, but the soonest I want to send ^A or ^C, nothing happens. It works fine for IE... but not Firefox.
 
Please help...
GeneralSetFocus...memberMember 438817726 Feb '10 - 2:31 
...did not work for me. In AppActivate you set the focus to a window. I've checked in code after the call if the handle is the focused window and it's not!?
 
Using MS Visual Studio 2005
 
Found and tried
AttachThreadInput(GetCurrentThreadId(), GetWindowThreadProcessId(wnd->m_hWnd, NULL), true)
but didn't help.
 
Any ideas?
GeneralDelay Vs. Holding the key downmemberValradica18 Sep '09 - 20:05 
In reading through the description above, it is not clear if the {DELAY 50} syntax just delays the onset of the next key to the KB buffer or whether it holds down the current key for 50ms. The original keyboard_event where you have to specify keydown and then keyup allows you to do this. I have a gaming application where I want to actually "press a key and hold it down until I release it" rather than repeatedly pressing it. Is this possible with Sendkeys C++?
QuestionRe: Delay Vs. Holding the key downmemberjagierek21 Aug '11 - 15:35 
The same problem. Does anybody know how to simulate this "press a key and hold it down until I release it".
GeneralBug in codememberSiddharth Hegde25 Aug '09 - 1:44 
Hello,
 
Firstly let me thank you for this excellent class. I would like to point you to a bug that came to light when I tried to add a few keys codes to the list.
 
In SendKeys.cpp line 325
int cmp = _tcsicmp(KeyNames[Middle].keyName, KeyString, _tcslen(KeyString));
should actually be
int cmp = _tcsicmp(KeyNames[Middle].keyName, KeyString);
This is because the existing code will match even in the following case, since you are forcing it to compare only the first 5 chars
_tcsicmp("RIGHTBRACE", "RIGHT", 5);
As of now, the binary search manages to escape this problem, but you may have problems extending it in the future.
 
HTH
 
- Sid
GeneralRe: Bug in codememberRafal07BC10 Feb '10 - 3:24 
You are absolutely right. This bug is causing for example F1 key to fail. Thanks I was checking why my code was not working and your comment was very helpful.
GeneralRe: Bug in codememberlarkyap13 Dec '11 - 3:34 
Yes, thank you! I was having a problem with sending {LEFT} due to {LEFTBRACE} being matched. I just changed to {LBRACE} and re-positioned it alphabetically above {LEFT}. Worked like a charm.
Questiondead diaeresis (umlaut)memberbustr5 Mar '09 - 13:25 
Is it possible to simulate (send) the dead diaeresis (umlaut) followed by a normal letter, with c++ code instead of with the keyboard?
 
I tried with keybd_event and SendMessage, but I cant get it to work.
SendMessage(hWnd,WM_KEYDOWN,(WPARAM)0x0308,0);
SendMessage(hWnd,WM_DEADCHAR,(WPARAM)0x0308,0);
SendMessage(hWnd,WM_KEYUP,(WPARAM)0x0308,0);
SendMessage(hWnd,WM_KEYDOWN,(WPARAM)0x0075,0);
SendMessage(hWnd,WM_CHAR,(WPARAM)0x0075,0);
SendMessage(hWnd,WM_KEYUP,(WPARAM)0x0075,0);
 
Thx
GeneralProblem with ESC key [modified]membervolodim21 Nov '08 - 13:03 
Hiya guys, I had some problems with the ESC key.
Just so you know, when you want to send ESCAPE to a program, This library will send a WM_KEYDOWN message with the parameter Extended set to 0, BUT it will send a WM_KEYUP message with the parameter Extended set to 1!
 
it caused some problems with one particular program I wanted to control by getting stuck in a loop.
 
Quick Hotfix:
I changed sendkeys.cpp by removing any references to the KEYEVENTF_EXTENDEDKEY flag so that it will never set this flag to 1 (I loose control of some keys but in my particular case, it does not matter).
 
Kudos to the author of this program Smile | :)
 
modified on Friday, November 21, 2008 7:11 PM

GeneralTrying to make it work in Borland Bilder or BloodShed Dev-Cppmemberlsanczyk18 Sep '08 - 8:42 
I have problemas doing this. When I add SendKeys.cpp and SendKeys.h to a proyect, I can't compile it. Can it be possible? Could someone do it? =(
 
I'll thank your help!
GeneralReading Text...memberPankajB10 Sep '08 - 7:31 
Hi There.
 
I need some technical help regarding your one of the article i.e., "SendKeys in C++".
 
Your article is one of the best articles I came across so far. At this point of moment, can you tell me how can I read the text written by your application on the active window?
 
I mean your application can activate a window and can write text on that window, Can you please help me out reading the same text?
 
In case you need any further info, then please let me know.
 
Thanks and Regards.
Pankaj
RantRe: Reading Text...mvpJames R. Twine11 Sep '08 - 8:50 
   Please do not cross-post (or double-post), pick either here or the Lounge, not both.
 
   Peace!
 
-=- James
Please rate this message - let me know if I helped or not!
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles



GeneralRe: Reading Text...memberPankajB11 Sep '08 - 17:28 
Sorry for that James Smile | :)
GeneralHelp with using it pleasememberAaron Feldspar13 Jun '08 - 13:01 
heres ma source code:
#include "cstdlib"
#include "iostream"
#include "windows.h"
#include "sendkeys.h"
using namespace std;
 
int main(int argc, char *argv[])
{
int menuStatus;
menuStatus = 1;
cout << "Welcome to the Harvest Moon Menu" << endl << endl;
cout << "Which game would you like to play?" << endl;
cout << "1:      Harvest Moon Game Boy 1" << endl; 
cout << "2:      Harvest Moon Game Boy 2" << endl;
cout << "3:      Harvest Moon Game Boy 3" << endl;
cout << "4:      Harvest Moon Friends of Mineral Town" << endl;
cout << "5:      Harvest Moon 64" << endl;
cin >> menuStatus;
if(menuStatus == 1)
{
FreeConsole();
system("c:/hvnm/hm1gbgb.gbc");
}
else if(menuStatus == 2)
{
FreeConsole();
system("c:/hvnm/hm2gbgb.gbc");
}
else if(menuStatus == 3)
{
FreeConsole();
system("c:/hvnm/hm3gbgb.gbc");
}
else if(menuStatus == 4)
{
FreeConsole();
system("c:/hvnm/hmfomt.gba");
}
else if(menuStatus == 5)
{
FreeConsole();
system("c:/hvnm/hm64.n64");
CSendKeys.SendKeys("{BREAK}");
}
    return 0;
    return EXIT_SUCCESS;
}
I'm getting an annoying result in the output window Frown | :(
expect primary-expression before '.' token
i also tried to use:
CSendKeys sk;
but that didn't help Hmmm | :|
 
I'm new to programming, and figured this would be a good way to practice ^^. Any help you could offer would be greatly appreciated.
 
I'm using dev c++ v 4.9.9.2 on windows xp: service pack 2.
 
again, thanks in advance! Smile | :)
 
edit: Eep! just noticed that message on the bottom D:!!
What's up with that :S
GeneralNeed .dll version that works with Windows Scripting HostmemberSharkD9 Jun '08 - 7:07 
I was wondering if someone could create a dll version that can be accessed using the Windows Scripting Host. I don't know C++ (just JScript and VBScript) and don't have any C++ IDEs installed.
 
Thanks!
QuestionCompilation error - Microsoft Visual C++ .NETmemberMayank Shridhar3 Jan '08 - 3:21 
We're writing a Visual C++ application which needs to emulate key-strokes upon a particular event. We've downloaded the code from this sample.
 
When we add a reference to this project in our Visual C++ project (in Visual Studio .NET 2003) and include the header-files using "#include "SendKeys.h", it gives compilation errors saying "unresolved external symbol public: bool __thiscall CSendKeys::SendKeys". We've also tried importing all the code of the attached project into our project and compiling it from scratch. However, this option does not work as well (though the attached project compiles independently).
 
Can somebody pls let me know the sequence of steps that we need to follow to include this in our code (separate project) and compile it?
 
Thanks, Mayank Shridhar.
GeneralRe: Compilation error - Microsoft Visual C++ .NETmemberValerie Anders3 Jan '08 - 4:31 
Check out this URL that contains a listing of "difficult to diagnose" error messages and possible fixes.
 
http://averia.unm.edu/VisualCPPErrorMessages.html[^]
 
It sounds like perhaps you have the .h file included, but don't actually have the class defined in your project.
AnswerRe: Compilation error - Microsoft Visual C++ .NETmemberIrken Santillan9 Jun '10 - 18:30 
Hi
 
I´ve the same problem did you solve it ? and how? if it's not much problem
 
thankyou
AnswerRe: Compilation error - Microsoft Visual C++ .NETmemberAdminSam16 Jan '12 - 0:10 
I too have same problem:
Errors i am getting on compile time.
Error 1: fatal error C1189: #error : _WIN32_WINNT settings conflicts with _WIN32_IE setting c:\program files\microsoft sdks\windows\v6.0a\include\sdkddkver.h 217 SendKeysSample
 
If commented the 3 line of code.
 
Error 2: error C2504: 'ICommDlgBrowser2' : base class undefined c:\program files\microsoft sdks\windows\v6.0a\include\shobjidl.h 6407 SendKeysSample
 
Please can you correct this and reattached the functioning source code.
Questionerror... :(memberjax509 Dec '07 - 17:23 
error C2664: 'CSendKeys::SendKeys' : cannot convert parameter 1 from 'const char [27]' to 'LPCTSTR'
 
says that when i try to compile can any one tell me how to fix Smile | :)
GeneralSending Text to Active Applicationmembervikrant kpr11 Oct '07 - 9:10 
Hi
 
Any idea how send keys to active application ? eg ie
 
Also in notepad if i reduce the time then all of it does not work properly
 
let's say we do not want delay then what?
 
Regards
GeneralRe: Sending Text to Active ApplicationmemberIrken Santillan9 Jun '10 - 18:23 
Hey
 
I`ve the same problem did you solve it ? and how ? if it's not too much problem..
 
Regards
GeneralI have a C# version if you want [modified]memberRobert Gasparotto11 Sep '07 - 16:34 
Hi lallous
 
Your code works great - thank you for the hard work.
 
I have a C# version of your code if you want. I wrapped the class into a VC++6 DLL and have created marshalled classes within C# - it works.
 
If you want I can give you the source code so you can look at / post / whatever.
 
Interested ?
 
Thanks,
Robert.
 
modified on Tuesday, April 15, 2008 10:55 PM

GeneralRe: I have a C# version if you wantmemberlallous11 Sep '07 - 19:41 
Hello Robert,
 
Thanks for your efforts.
 
This sounds a good idea.
 
Another idea might be to try to compile the project as a class library directly from a C++/CLI projects, probably it will work, thus you will have just one assembly written in mixed code.
 
I don't know much VB, doesn't VB.NET have a SendKeys functionality? thus if you add appropriate references from C# you can SendKeys as well?
 
p.s: if you have a website, please post a direct link in a dedicated thread in here.
 
Regards,
Elias
GeneralRe: I have a C# version if you wantmemberRobert Gasparotto12 Sep '07 - 18:07 
My bad - the C# SendKeys actually works fairly well
 
Oh well Wink | ;-) - learnt how to wrap C++ classes for C# anyway
 

GeneralRe: I have a C# version if you wantmemberleeand22 Jul '11 - 2:49 
I need to send keypad keys ( not supported via c# sendkey). Although this is an older thread - can I ask for the c# wrapper to: lulej@tpg.com.au
thanks
Andreas
QuestionRe: I have a C# version if you wantmemberFuzzychaos14 Oct '07 - 22:24 
Hi Robert,
 
I need a C# version, can you please e-mail it to me or post a link for download?
 
Thanks,
 
Jeremy
 
Props to the family: New Dawn Engineering

AnswerRe: I have a C# version if you want [modified]memberRobert Gasparotto16 Oct '07 - 19:33 
what is your email address ?
btw - the native C# SendKeys works perfectly - I am using that constantly and dont touch the dll I made
if you want I can still email you the project though
 
modified on Tuesday, April 15, 2008 10:56 PM

GeneralRe: I have a C# version if you wantmemberalper ebicoglu4 Oct '08 - 11:31 
Hi,
 

Can you send me your marshalled C# SendKeys project. I need to send keystrokes to DOS window.
alperonline@hotmail.com
AnswerRe: I have a C# version if you wantmemberFuzzychaos24 Oct '07 - 23:44 
Just so that everyone knows. The C# SendKeys() doesn't work on DOS mode programs like EDIT.COM but this project does. I converted the entire thing to C#. Its not perfect because I don't know how to do proper marshalling of structs for the enumwindowsProc, but it does work properly (since I'm using FindWindow()/FindWindowEx()).
 
Jeremy
 
Props to the family: New Dawn Engineering

GeneralRe: I have a C# version if you wantmemberdzCepheus26 Nov '07 - 20:06 
Got a download available somewhere? Or can you send it to erikforbes@gmail.com?
 
PS: This is what part of the alphabet would look like if the letters Q and R were removed.

GeneralRe: I have a C# version if you wantmemberhdjim5 Dec '07 - 3:49 
Hello,
 
I would love to have your C# version. Would you be so kind to send it to me at rhe following email address:
 
jim_greene@jabil.com
 
Thanks in advance!
 
Best regards,
Jim
GeneralRe: I have a C# version if you wantmemberInternetIllusion3 Jun '10 - 5:08 
I have been searching for a way to send the Windows key to another computer with no luck using SendKeys. Your C# code sounds exactly what I am looking for.
 
Please send a copy to me - internetillusion@yahoo.com
GeneralRe: I have a C# version if you wantmemberr.guerzoni20 Mar '08 - 3:41 
Hi Robert,
 
I need a C# version too, can you please e-mail it to me or post a link for download?
 
Thanks,
Roberto
GeneralRe: I have a C# version if you wantmembermanishjain764 May '08 - 22:27 
Hi!,
 
can you share the C# version and send it to this mail id:
manish_jain06@infosys.com
 
regards,
Manish
GeneralRe: I have a C# version if you wantmemberGicks16 Jun '08 - 6:56 
Hi Robert,
 
I would like to get your C# version.
Could you send it to Gicks@free.fr
 
Thank's a lot.
GeneralRe: I have a C# version if you wantmemberF1dave17 Jun '08 - 10:53 
Hi,
 
I know you get a lot of requests like mine but please do share... I have been searching for months for this.
 
Can you send to laplante_rooster@hotmail.com ?
 
Thanks for your time and effort!
Dave
GeneralRe: I have a C# version if you wantmemberTolis_200123 Aug '08 - 23:31 
Hi!,
 
can you share the C# version and send it to the following mail:
Tolis_2001@hotmail.com
 
Thanks in advance,
Tolis
GeneralRe: I have a C# version if you wantmemberFriedemann30 Aug '08 - 9:41 
Can you please mail me the C#-Version, too?
My e-mail adress: spamarea-scriptmail@yahoo.de
 
Thank you
GeneralRe: I have a C# version if you wantmemberstefan stoian5 Sep '08 - 10:48 
Hi
 
Can u send the c# version to audi_rs7@yahoo.com ?
 
Thank you very much
GeneralRe: I have a C# version if you wantmemberr.guerzoni24 Sep '08 - 3:44 
Hi Robert,
I'm also interest into your translation.
Could you send it to me too?
Thanks
Roberto Guerzoni
GeneralRe: I have a C# version if you wantmemberMicah Peterson28 Apr '09 - 16:36 
Hi Robert,
 
I would love to check your code out! Would you be able to email it to micahandkatie@gmail.com ? Thanks! Micah
Generalproblem with key up eventsmemberAndrew Palka6 Jul '07 - 23:03 
I had a strange problem running this on my laptop.
It mostly worked but produced some strange effects such as changing the volume/brightness or activating other function keys.
 
This seems to be a problem with generating the key up event.
 
KeyboardEvent(VKey, ScanCode, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP);
 
This always sets the KEYEVENTF_EXTENDEDKEY flag. Mostly this is harmless, but it seems that the key up events are used by the function key handling on my laptop.
 
The correct code should only set the flag when it is needed (the same as the key down event).
E.g.
KeyboardEvent(VKey, ScanCode, (IsVkExtended(VKey) ? KEYEVENTF_EXTENDEDKEY : 0) | KEYEVENTF_KEYUP);
 

QuestionI am getting error while including in my project.membershivditya14 Jun '07 - 5:58 

Your article is very very good,no doubt you have done increditable work and made
easy many peoples life like me.
I included your sendkey class .h and .cpp file in project on which I am working but it gives error at INPUT function, and SendInput function. That file is User32.lib file or in windows.h header or winuser.h . I included these files, but it gives error global function not declared. I dont know how to use.
One more thing
in AppActivate function you have written at a place ::SetForeGroundWindow(hwnd)
without which code doesnot give result,but for my application it is unwanted,as
I am behind removing unwanted MessageBox which Earlier engineer left in his dll whos
code is not with me.And I found I can work out well because of your contribution
to universal code.Will you please let me know,how to solve these problems.
 
|| ART OF LIVING ||

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 15 Jun 2004
Article Copyright 2004 by Elias Bachaalany
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid