Not a member yet? Register for your free account!


You last visited: Today at 12:19

  • Please register to post and access all features, it's quick, easy and FREE!

 

Simulating Keystrokes

This is a discussion on Simulating Keystrokes within the General Gaming Releases forum part of the General Gaming Discussion category; Hi folks, usually I am not releasing my stuff. But here is a small hint for "do it yourself" people, ...

Reply
 
Thread Tools
Old   #1
Junior Member
 
Join Date: Jun 2005
Posts: 8
Received Thanks: 2
Simulating Keystrokes


Hi folks,

usually I am not releasing my stuff. But here is a small hint for "do it yourself" people, how to simulate keystrokes for Warhammer Online.

The usual way to do that via Postmessage or kbdevent does NOT work here, because Warhammer is a DirectInput game.

It cost me some hours to figure out a proper but easy way how to do it:


INPUT input;
memset(&input,0,sizeof(INPUT));
input.type=INPUT_KEYBOARD;
input.ki.wScan =DIKEYBOARD_1; // direct-input scancode for key '1'
if(press_key) input.ki.dwFlags=0;
else input.ki.dwFlags=KEYEVENTF_KEYUP;
SendInput(1,&input,sizeof(INPUT));



This example will properly work for XT and Vista.
The trick is simply NOT to use VK_'s, but the lower 16 bits of DirectX scancodes. Try to google for DIKEYBOARD_1 and you will find them all.

Have Fun with it.

apollo

PS: It seems to be hard to find the right one, so I post those scancodes here:

#ifndef DIRECT_X_KEYS_HPP_DEFINED
#define DIRECT_X_KEYS_HPP_DEFINED

#define DIKEYBOARD_ESCAPE 0x0401 //
#define DIKEYBOARD_1 0x0402 //
#define DIKEYBOARD_2 0x0403 //
#define DIKEYBOARD_3 0x0404 //
#define DIKEYBOARD_4 0x0405 //
#define DIKEYBOARD_5 0x0406 //
#define DIKEYBOARD_6 0x0407 //
#define DIKEYBOARD_7 0x0408 //
#define DIKEYBOARD_8 0x0409 //
#define DIKEYBOARD_9 0x040A //
#define DIKEYBOARD_0 0x040B //
#define DIKEYBOARD_MINUS 0x040C // (* - on main keyboard *)
#define DIKEYBOARD_EQUALS 0x040D //
#define DIKEYBOARD_BACK 0x040E // (* backspace *)
#define DIKEYBOARD_TAB 0x040F //
#define DIKEYBOARD_Q 0x0410 //
#define DIKEYBOARD_W 0x0411 //
#define DIKEYBOARD_E 0x0412 //
#define DIKEYBOARD_R 0x0413 //
#define DIKEYBOARD_T 0x0414 //
#define DIKEYBOARD_Y 0x0415 //
#define DIKEYBOARD_U 0x0416 //
#define DIKEYBOARD_I 0x0417 //
#define DIKEYBOARD_O 0x0418 //
#define DIKEYBOARD_P 0x0419 //
#define DIKEYBOARD_LBRACKET 0x041A //
#define DIKEYBOARD_RBRACKET 0x041B //
#define DIKEYBOARD_RETURN 0x041C // (* Enter on main keyboard *)
#define DIKEYBOARD_LCONTROL 0x041D //
#define DIKEYBOARD_A 0x041E //
#define DIKEYBOARD_S 0x041F //
#define DIKEYBOARD_D 0x0420 //
#define DIKEYBOARD_F 0x0421 //
#define DIKEYBOARD_G 0x0422 //
#define DIKEYBOARD_H 0x0423 //
#define DIKEYBOARD_J 0x0424 //
#define DIKEYBOARD_K 0x0425 //
#define DIKEYBOARD_L 0x0426 //
#define DIKEYBOARD_SEMICOLON 0x0427 //
#define DIKEYBOARD_APOSTROPHE 0x0428 //
#define DIKEYBOARD_GRAVE 0x0429 // (* accent grave *)
#define DIKEYBOARD_LSHIFT 0x042A //
#define DIKEYBOARD_BACKSLASH 0x042B //
#define DIKEYBOARD_Z 0x042C //
#define DIKEYBOARD_X 0x042D //
#define DIKEYBOARD_C 0x042E //
#define DIKEYBOARD_V 0x042F //
#define DIKEYBOARD_B 0x0430 //
#define DIKEYBOARD_N 0x0431 //
#define DIKEYBOARD_M 0x0432 //
#define DIKEYBOARD_COMMA 0x0433 //
#define DIKEYBOARD_PERIOD 0x0434 // (* . on main keyboard *)
#define DIKEYBOARD_SLASH 0x0435 // (* / on main keyboard *)
#define DIKEYBOARD_RSHIFT 0x0436 //
#define DIKEYBOARD_MULTIPLY 0x0437 // (* * on numeric keypad *)
#define DIKEYBOARD_LMENU 0x0438 // (* left Alt *)
#define DIKEYBOARD_SPACE 0x0439 //
#define DIKEYBOARD_CAPITAL 0x043A //
#define DIKEYBOARD_F1 0x043B //
#define DIKEYBOARD_F2 0x043C //
#define DIKEYBOARD_F3 0x043D //
#define DIKEYBOARD_F4 0x043E //
#define DIKEYBOARD_F5 0x043F //
#define DIKEYBOARD_F6 0x0440 //
#define DIKEYBOARD_F7 0x0441 //
#define DIKEYBOARD_F8 0x0442 //
#define DIKEYBOARD_F9 0x0443 //
#define DIKEYBOARD_F10 0x0444 //
#define DIKEYBOARD_NUMLOCK 0x0445 //
#define DIKEYBOARD_SCROLL 0x0446 // (* Scroll Lock *)
#define DIKEYBOARD_NUMPAD7 0x0447 //
#define DIKEYBOARD_NUMPAD8 0x0448 //
#define DIKEYBOARD_NUMPAD9 0x0449 //
#define DIKEYBOARD_SUBTRACT 0x044A // (* - on numeric keypad *)
#define DIKEYBOARD_NUMPAD4 0x044B //
#define DIKEYBOARD_NUMPAD5 0x044C //
#define DIKEYBOARD_NUMPAD6 0x044D //
#define DIKEYBOARD_ADD 0x044E // (* + on numeric keypad *)
#define DIKEYBOARD_NUMPAD1 0x044F //
#define DIKEYBOARD_NUMPAD2 0x0450 //
#define DIKEYBOARD_NUMPAD3 0x0451 //
#define DIKEYBOARD_NUMPAD0 0x0452 //
#define DIKEYBOARD_DECIMAL 0x0453 // (* . on numeric keypad *)
#define DIKEYBOARD_OEM_102 0x0456 // (* < > | on UK/Germany keyboards *)
#define DIKEYBOARD_F11 0x0457 //
#define DIKEYBOARD_F12 0x0458 //
#define DIKEYBOARD_F13 0x0464 // (* (NEC PC98) *)
#define DIKEYBOARD_F14 0x0465 // (* (NEC PC98) *)
#define DIKEYBOARD_F15 0x0466 // (* (NEC PC98) *)
#define DIKEYBOARD_KANA 0x0470 // (* (Japanese keyboard) *)
#define DIKEYBOARD_ABNT_C1 0x0473 // (* / ? on Portugese (Brazilian) keyboards *)
#define DIKEYBOARD_CONVERT 0x0479 // (* (Japanese keyboard) *)
#define DIKEYBOARD_NOCONVERT 0x047B // (* (Japanese keyboard) *)
#define DIKEYBOARD_YEN 0x047D // (* (Japanese keyboard) *)
#define DIKEYBOARD_ABNT_C2 0x047E // (* Numpad . on Portugese (Brazilian) keyboards *)
#define DIKEYBOARD_NUMPADEQUALS 0x048D // (* = on numeric keypad (NEC PC98) *)
#define DIKEYBOARD_PREVTRACK 0x0490 // (* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) *)
#define DIKEYBOARD_AT 0x0491 // (* (NEC PC98) *)
#define DIKEYBOARD_COLON 0x0492 // (* (NEC PC98) *)
#define DIKEYBOARD_UNDERLINE 0x0493 // (* (NEC PC98) *)
#define DIKEYBOARD_KANJI 0x0494 // (* (Japanese keyboard) *)
#define DIKEYBOARD_STOP 0x0495 // (* (NEC PC98) *)
#define DIKEYBOARD_AX 0x0496 // (* (Japan AX) *)
#define DIKEYBOARD_UNLABELED 0x0497 // (* (J3100) *)
#define DIKEYBOARD_NEXTTRACK 0x0499 // (* Next Track *)
#define DIKEYBOARD_NUMPADENTER 0x049C // (* Enter on numeric keypad *)
#define DIKEYBOARD_RCONTROL 0x049D //
#define DIKEYBOARD_MUTE 0x04A0 // (* Mute *)
#define DIKEYBOARD_CALCULATOR 0x04A1 // (* Calculator *)
#define DIKEYBOARD_PLAYPAUSE 0x04A2 // (* Play / Pause *)
#define DIKEYBOARD_MEDIASTOP 0x04A4 // (* Media Stop *)
#define DIKEYBOARD_VOLUMEDOWN 0x04AE // (* Volume - *)
#define DIKEYBOARD_VOLUMEUP 0x04B0 // (* Volume + *)
#define DIKEYBOARD_WEBHOME 0x04B2 // (* Web home *)
#define DIKEYBOARD_NUMPADCOMMA 0x04B3 // (* , on numeric keypad (NEC PC98) *)
#define DIKEYBOARD_DIVIDE 0x04B5 // (* / on numeric keypad *)
#define DIKEYBOARD_SYSRQ 0x04B7 //
#define DIKEYBOARD_RMENU 0x04B8 // (* right Alt *)
#define DIKEYBOARD_PAUSE 0x04C5 // (* Pause *)
#define DIKEYBOARD_HOME 0x04C7 // (* Home on arrow keypad *)
#define DIKEYBOARD_UP 0x04C8 // (* UpArrow on arrow keypad *)
#define DIKEYBOARD_PRIOR 0x04C9 // (* PgUp on arrow keypad *)
#define DIKEYBOARD_LEFT 0x04CB // (* LeftArrow on arrow keypad *)
#define DIKEYBOARD_RIGHT 0x04CD // (* RightArrow on arrow keypad *)
#define DIKEYBOARD_END 0x04CF // (* End on arrow keypad *)
#define DIKEYBOARD_DOWN 0x04D0 // (* DownArrow on arrow keypad *)
#define DIKEYBOARD_NEXT 0x04D1 // (* PgDn on arrow keypad *)
#define DIKEYBOARD_INSERT 0x04D2 // (* Insert on arrow keypad *)
#define DIKEYBOARD_DELETE 0x04D3 // (* Delete on arrow keypad *)
#define DIKEYBOARD_LWIN 0x04DB // (* Left Windows key *)
#define DIKEYBOARD_RWIN 0x04DC // (* Right Windows key *)
#define DIKEYBOARD_APPS 0x04DD // (* AppMenu key *)
#define DIKEYBOARD_POWER 0x04DE // (* System Power *)
#define DIKEYBOARD_SLEEP 0x04DF // (* System Sleep *)
#define DIKEYBOARD_WAKE 0x04E3 // (* System Wake *)
#define DIKEYBOARD_WEBSEARCH 0x04E5 // (* Web Search *)
#define DIKEYBOARD_WEBFAVORITES 0x04E6 // (* Web Favorites *)
#define DIKEYBOARD_WEBREFRESH 0x04E7 // (* Web Refresh *)
#define DIKEYBOARD_WEBSTOP 0x04E8 // (* Web Stop *)
#define DIKEYBOARD_WEBFORWARD 0x04E9 // (* Web Forward *)
#define DIKEYBOARD_WEBBACK 0x04EA // (* Web Back *)
#define DIKEYBOARD_MYCOMPUTER 0x04EB // (* My Computer *)
#define DIKEYBOARD_MAIL 0x04EC // (* Mail *)
#define DIKEYBOARD_MEDIASELECT 0x04ED // (* Media Select *)



#endif

__________________


Last edited by apollo; 09/25/2008 at 16:41.
apollo is offline  
Thanks
2 Users
mondesser (09/30/2008), numbgalore (10/27/2008)
Old 09/26/2008, 20:45   #2
DAMNCheaters.com Coder
 
Join Date: Oct 2004
Posts: 550
Received Thanks: 181
instead of using a buttload of defines one could also use MapVirtualKey(); instead... works fine.
Itburnz is offline  
Old 09/26/2008, 22:57   #3
Old School Gamer
 
Join Date: Jan 2006
Posts: 400
Received Thanks: 388
this is a nice find. to bad i dont do bots anymore :P ( my girlfriend would kill me - she loves this game >.> )
Tingle is offline  
Old 10/25/2008, 15:36   #4
Junior Member
 
Join Date: Oct 2008
Posts: 7
Received Thanks: 0
Hallo,

hat jemand mit dem Code hier schonmal erfolgreich eine Taste Simulieren können?

Ich verzweifle nämlich momentan daran - Und inzwischen glaube ich das vielleicht der obige Code nicht funktioniert (benutze VB.Net - Hab den C++ Code übersetzt bekommen.

Hab natürlich schon hier im Forum einen Thread aufgemacht (möglichkeiten zum Simulieren eine Taste) aber leider bisher ohne erfolg.

Danke im Voraus.
Micha01 is offline  
Old 10/28/2008, 07:58   #5
Junior Member
 
Join Date: Oct 2008
Posts: 7
Received Thanks: 0
Guten Morgen,

also ich habe mich nun in den letzten Tagen etwas mit dem Code hier beschäftigt:

Code:
	INPUT input;
	memset(&input,0,sizeof(INPUT));
	input.type=INPUT_KEYBOARD;
	input.ki.wScan =0x0402; 
	input.ki.dwFlags=0;
	SendInput(1,&input,sizeof(INPUT));

	return 0;
Jedoch ohne erfolg egal welche Taste ich versuche es kommt nichts bei Warhammer an.

Ich habe mir dann mal r die genaue API Delaration zu SendInput angeschaut und hab folgenden Code versucht (hier extra ein C++ Code da es doch einige mehr Leute gibt mit dieser Sprache hier im Forum):

Code:
     INPUT InputData;
	int iEvents;

	InputData.type = INPUT_KEYBOARD;
	InputData.ki.wVk = 0;
	InputData.ki.wScan = 0x0402;
	InputData.ki.dwFlags = 0;
	InputData.ki.time = time(NULL);
	InputData.ki.dwExtraInfo = 0;

	iEvents = SendInput(1, &InputData, sizeof(InputData));
Nun kommen die Taste zwar im Aktivn Fenster an (z.b: Notepad) aber nicht bei Warhammer!

Ich bin am bald am ende ... Ich habe schon soviele "mini" Tools gesehen, die es erfolgreich schaffen eine Taste zu Simulieren!

Wenn jemand ein Beispiel hat (inzwischen ist mir die Sprache egal) für das erfolgreichen Simulieren einer Taste wäre ich sehr dankbar
Micha01 is offline  
Old 11/11/2008, 21:35   #6
Junior Member
 
Join Date: Jan 2008
Posts: 1
Received Thanks: 0
Hallo!

Klingt vielleicht blöd, aber haste das Programm mal als Administrator gestartet? Hatte das Problem mit TeamSpeak: Push-to-Talk funktionierte nichtmehr sobald WAR aktiv war. TS als Administrator gestartet und schon kamen die Tasten wieder an...

Grüße u0000
u0000 is offline  
Old 08/20/2011, 00:31   #7
Junior Member
 
Join Date: Aug 2011
Posts: 1
Received Thanks: 0
awsome code snippit this will definetly help everyone

Last edited by giuseppe105; 08/20/2011 at 17:43.
giuseppe105 is offline  
Old 11/18/2011, 05:45   #8
Junior Member
 
Join Date: Aug 2008
Posts: 3
Received Thanks: 0
I am trying to recreate this for Free Pascal and gotta be missing something, is there a uses file I should use other then windows?
j3n7il is offline  
Reply

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
The difference between hard/software keystrokes HKNewB 9Dragons 2 02/17/2009 00:25
Simulating clicks? _fobos_ CO2 Programming 13 12/15/2008 00:13
How can i send keystrokes to an application in background Drakonis Archlord 3 04/09/2008 11:26
Verschiedene Arten um Keystrokes zu simulieren? pengpong General Coding 9 08/04/2007 04:34
simulating a keypress + no fog hack mickcr Guild Wars 15 08/26/2005 19:25



All times are GMT +2. The time now is 12:19.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.