tom99 Posted October 26, 2012 Share Posted October 26, 2012 (edited) hello i'm trying to make a script for guild wars 2 i found out all you need to do is press C followed by 1 then F to pickup. however the game dont react to sendkeys but aparently it react to sendinput in C# see example http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx is there a way to use sendinput in scar? I tried sendkeys,sendkeysvb,typekeys,keydown nothing. so is there a way to use the sendinput function? thanks! Edited October 26, 2012 by tom99 Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 hello i'm trying to make a script for guild wars 2 i found out all you need to do is press C followed by 1 then F to pickup. however the game dont react to sendkeys but aparently it react to sendinput in C# see example http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx is there a way to use sendinput in scar? I tried sendkeys,sendkeysvb,typekeys,keydown nothing. so is there a way to use the sendinput function? thanks! Are you using the latest version of SCAR? SendKeys, SendKeysVB and TypeKeys are no longer part of SCAR. All of the keyboard input functions in the latest version of SCAR are based off of the SendInput API. Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 i'm not using the latest version because all the functions has been changed and its confusing but will it work then? Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 i'm not using the latest version because all the functions has been changed and its confusing but will it work then? I don't know, you'll have to try... Some games block "fake" input events, which is possible as Windows internally keeps a flag that can tell applications whether the input came from a driver or from the SendInput/keybd_event API. Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 but when i press f1 and look on the documentation i only see the old functions where can i find the functions for the current scar version? btw the chat in the game react on sendkeys but the movements functions don't. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 I haven't had the time to finish documenting the entire new API yet. If you want to send arrow keys (I guess?) you should look into using [wiki=VKeyDown]VKeyDown[/wiki] with the constants VK_UP, VK_RIGHT, VK_DOWN and VK_LEFT. You release with [wiki=VKeyUp]VKeyUp[/wiki]. Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 i only need 3 keys target closest enemy which is C hit autoattack which is 1 and pickup which is F to get it working i could add more functions as i go. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 Well, I'd recommend using PressVKeyEx or PressKeyEx. They allow you to press a key and specify an interval in between holding and releasing. PressVKeyEx(CharToVKey('c'), 100); PressKeyEx('c', 100); Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 still nothing happens in the game. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 Well, this uses the SendInput API. If this doesn't work, the game probably doesn't accept the input events. Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 it must be a way I've seen crowds of other bots running around if it did not accept inputs how do you play? are you sure there is not other functions Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 Virtual input drivers, dll injection, packet botting, ... There's lots of ways really... Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 26, 2012 Share Posted October 26, 2012 Reminds me I forgot to put the keyb_event functin into a dll for SCAR. I think ill do this today and post it here later. Did you try the keybd_event function for your game? Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 26, 2012 Author Share Posted October 26, 2012 Did you try the keybd_event function for your game? No i haven't i really have not used scar for so much advanced things so i have not grasped the new functions yet and lack of documentation is giving me problems but i would love to try. do you have any ideas of how i could use virtual input drivers? there is already a lot of bots in the game and its pretty new so i have a hard time of believing they use injection. but maybe it would be the only way at least for more advanced things where you have to move as there is no point movement. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 26, 2012 Share Posted October 26, 2012 Reminds me I forgot to put the keyb_event functin into a dll for SCAR. I think ill do this today and post it here later. Did you try the keybd_event function for your game? Didn't we go over this? SendInput is basically the same thing. Also, the old version of SCAR he tried first uses Keybd_event. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 26, 2012 Share Posted October 26, 2012 We did yes. But I want to do this any way because they are different, and one game i tried keybd input would work and not sendinput. I used SCAR and every function then i used keybd input in it and it worked. As for other options sendinput is very customizable i read you could try passing different scan codes and other things... Blue macro has virtual mouse and keyboard drivers but idc for their software Quote Link to comment Share on other sites More sharing options...
tom99 Posted October 27, 2012 Author Share Posted October 27, 2012 I don't know this function keybd either when will the new documentation be ready and what is the syntax so i can try it? Btw it is possible to do this using only colors but they are so blended it will be very unreliable and a lot of work to change fighting spots Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 (edited) Alright well here's my first try at the plugin. Tried to include Direct Input as well. However both functions I have not been able to test out really too much with games and what not. Direct Input is supposed to be for DirectX games... You need the DirectInput constants too for the function DirectKeyDown..DirectKeyUp..etc: Example test file: Keybd is in there too as KeybdDown KeybdUp (Use VKeys) [scar] program New; {$L Keyboard.dll} const DIKEYBOARD_ESCAPE = $0401; DIKEYBOARD_1 = $0402; DIKEYBOARD_2 = $0403; DIKEYBOARD_3 = $0404; DIKEYBOARD_4 = $0405; DIKEYBOARD_5 = $0406; DIKEYBOARD_6 = $0407; DIKEYBOARD_7 = $0408; DIKEYBOARD_8 = $0409; DIKEYBOARD_9 = $040A; DIKEYBOARD_0 = $040B; DIKEYBOARD_MINUS = $040C; // (* - on main keyboard *) DIKEYBOARD_EQUALS = $040D; // DIKEYBOARD_BACK = $040E; // (* backspace *) DIKEYBOARD_TAB = $040F; // DIKEYBOARD_Q = $0410; // DIKEYBOARD_W = $0411; // DIKEYBOARD_E = $0412; // DIKEYBOARD_R = $0413; // DIKEYBOARD_T = $0414; // DIKEYBOARD_Y = $0415; // DIKEYBOARD_U = $0416; // DIKEYBOARD_I = $0417; // DIKEYBOARD_O = $0418; // DIKEYBOARD_P = $0419; // DIKEYBOARD_LBRACKET = $041A; // DIKEYBOARD_RBRACKET = $041B; // DIKEYBOARD_RETURN = $041C; // (* Enter on main keyboard *) DIKEYBOARD_LCONTROL = $041D; // DIKEYBOARD_A = $041E; // DIKEYBOARD_S = $041F; // DIKEYBOARD_D = $0420; // DIKEYBOARD_F = $0421; // DIKEYBOARD_G = $0422; // DIKEYBOARD_H = $0423; // DIKEYBOARD_J = $0424; // DIKEYBOARD_K = $0425; // DIKEYBOARD_L = $0426; // DIKEYBOARD_SEMICOLON = $0427; // DIKEYBOARD_APOSTROPHE = $0428; // DIKEYBOARD_GRAVE = $0429; // (* accent grave *) DIKEYBOARD_LSHIFT = $042A; // DIKEYBOARD_BACKSLASH = $042B; // DIKEYBOARD_Z = $042C; // DIKEYBOARD_X = $042D; // DIKEYBOARD_C = $042E; // DIKEYBOARD_V = $042F; // DIKEYBOARD_B = $0430; // DIKEYBOARD_N = $0431; // DIKEYBOARD_M = $0432; // DIKEYBOARD_COMMA = $0433; // DIKEYBOARD_PERIOD = $0434; // (* . on main keyboard *) DIKEYBOARD_SLASH = $0435; // (* / on main keyboard *) DIKEYBOARD_RSHIFT = $0436; // DIKEYBOARD_MULTIPLY = $0437; // (* * on numeric keypad *) DIKEYBOARD_LMENU = $0438; // (* left Alt *) DIKEYBOARD_SPACE = $0439; // DIKEYBOARD_CAPITAL = $043A; // DIKEYBOARD_F1 = $043B; // DIKEYBOARD_F2 = $043C; // DIKEYBOARD_F3 = $043D; // DIKEYBOARD_F4 = $043E; // DIKEYBOARD_F5 = $043F; // DIKEYBOARD_F6 = $0440; // DIKEYBOARD_F7 = $0441; // DIKEYBOARD_F8 = $0442; // DIKEYBOARD_F9 = $0443; // DIKEYBOARD_F10 = $0444; // DIKEYBOARD_NUMLOCK = $0445; // DIKEYBOARD_SCROLL = $0446; // (* Scroll Lock *) DIKEYBOARD_NUMPAD7 = $0447; // DIKEYBOARD_NUMPAD8 = $0448; // DIKEYBOARD_NUMPAD9 = $0449; // DIKEYBOARD_SUBTRACT = $044A; // (* - on numeric keypad *) DIKEYBOARD_NUMPAD4 = $044B; // DIKEYBOARD_NUMPAD5 = $044C; // DIKEYBOARD_NUMPAD6 = $044D; // DIKEYBOARD_ADD = $044E; // (* + on numeric keypad *) DIKEYBOARD_NUMPAD1 = $044F; // DIKEYBOARD_NUMPAD2 = $0450; // DIKEYBOARD_NUMPAD3 = $0451; // DIKEYBOARD_NUMPAD0 = $0452; // DIKEYBOARD_DECIMAL = $0453; // (* . on numeric keypad *) DIKEYBOARD_OEM_102 = $0456; // (* < > | on UK/Germany keyboards *) DIKEYBOARD_F11 = $0457; // DIKEYBOARD_F12 = $0458; // DIKEYBOARD_F13 = $0464; // (* (NEC PC98) *) DIKEYBOARD_F14 = $0465; // (* (NEC PC98) *) DIKEYBOARD_F15 = $0466; // (* (NEC PC98) *) DIKEYBOARD_KANA = $0470; // (* (Japanese keyboard) *) DIKEYBOARD_ABNT_C1 = $0473; // (* / ? on Portugese (Brazilian) keyboards *) DIKEYBOARD_CONVERT = $0479; // (* (Japanese keyboard) *) DIKEYBOARD_NOCONVERT = $047B; // (* (Japanese keyboard) *) DIKEYBOARD_YEN = $047D; // (* (Japanese keyboard) *) DIKEYBOARD_ABNT_C2 = $047E; // (* Numpad . on Portugese (Brazilian) keyboards *) DIKEYBOARD_NUMPADEQUALS = $048D; // (* = on numeric keypad (NEC PC98) *) DIKEYBOARD_PREVTRACK = $0490; // (* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) *) DIKEYBOARD_AT = $0491; // (* (NEC PC98) *) DIKEYBOARD_COLON = $0492; // (* (NEC PC98) *) DIKEYBOARD_UNDERLINE = $0493; // (* (NEC PC98) *) DIKEYBOARD_KANJI = $0494; // (* (Japanese keyboard) *) DIKEYBOARD_STOP = $0495; // (* (NEC PC98) *) DIKEYBOARD_AX = $0496; // (* (Japan AX) *) DIKEYBOARD_UNLABELED = $0497; // (* (J3100) *) DIKEYBOARD_NEXTTRACK = $0499; // (* Next Track *) DIKEYBOARD_NUMPADENTER = $049C; // (* Enter on numeric keypad *) DIKEYBOARD_RCONTROL = $049D; // DIKEYBOARD_MUTE = $04A0; // (* Mute *) DIKEYBOARD_CALCULATOR = $04A1; // (* Calculator *) DIKEYBOARD_PLAYPAUSE = $04A2; // (* Play / Pause *) DIKEYBOARD_MEDIASTOP = $04A4; // (* Media Stop *) DIKEYBOARD_VOLUMEDOWN = $04AE; // (* Volume - *) DIKEYBOARD_VOLUMEUP = $04B0; // (* Volume + *) DIKEYBOARD_WEBHOME = $04B2; // (* Web home *) DIKEYBOARD_NUMPADCOMMA = $04B3; // (* , on numeric keypad (NEC PC98) *) DIKEYBOARD_DIVIDE = $04B5; // (* / on numeric keypad *) DIKEYBOARD_SYSRQ = $04B7; // DIKEYBOARD_RMENU = $04B8; // (* right Alt *) DIKEYBOARD_PAUSE = $04C5; // (* Pause *) DIKEYBOARD_HOME = $04C7; // (* Home on arrow keypad *) DIKEYBOARD_UP = $04C8; // (* UpArrow on arrow keypad *) DIKEYBOARD_PRIOR = $04C9; // (* PgUp on arrow keypad *) DIKEYBOARD_LEFT = $04CB; // (* LeftArrow on arrow keypad *) DIKEYBOARD_RIGHT = $04CD; // (* RightArrow on arrow keypad *) DIKEYBOARD_END = $04CF; // (* End on arrow keypad *) DIKEYBOARD_DOWN = $04D0; // (* DownArrow on arrow keypad *) DIKEYBOARD_NEXT = $04D1; // (* PgDn on arrow keypad *) DIKEYBOARD_INSERT = $04D2; // (* Insert on arrow keypad *) DIKEYBOARD_DELETE = $04D3; // (* Delete on arrow keypad *) DIKEYBOARD_LWIN = $04DB; // (* Left Windows key *) DIKEYBOARD_RWIN = $04DC; // (* Right Windows key *) DIKEYBOARD_APPS = $04DD; // (* AppMenu key *) DIKEYBOARD_POWER = $04DE; // (* System Power *) DIKEYBOARD_SLEEP = $04DF; // (* System Sleep *) DIKEYBOARD_WAKE = $04E3; // (* System Wake *) DIKEYBOARD_WEBSEARCH = $04E5; // (* Web Search *) DIKEYBOARD_WEBFAVORITES = $04E6; // (* Web Favorites *) DIKEYBOARD_WEBREFRESH = $04E7; // (* Web Refresh *) DIKEYBOARD_WEBSTOP = $04E8; // (* Web Stop *) DIKEYBOARD_WEBFORWARD = $04E9; // (* Web Forward *) DIKEYBOARD_WEBBACK = $04EA; // (* Web Back *) DIKEYBOARD_MYCOMPUTER = $04EB; // (* My Computer *) DIKEYBOARD_MAIL = $04EC; // (* Mail *) DIKEYBOARD_MEDIASELECT = $04ED; // (* Media Select *) begin GetClient.Activate; //ClickMouse(280, 211, mbleft); WriteLn('Testing directinput 2 seconds'); DirectKeyDown(DIKEYBOARD_W); DirectKeyUp(DIKEYBOARD_W); WriteLn('Testing keybd input 2 seconds'); KeybdDown(CharToVKey('w')); KeybdUp(CharToVKey('w')); WriteLn('Testing SCAR input 2 seconds'); VKeyDown(CharToVKey('w')); VKeyUp(CharToVKey('w')); WriteLn('Testing escape button Direct input 2 seconds'); DirectKeyDown(DIKEYBOARD_ESCAPE); DirectKeyUp(DIKEYBOARD_ESCAPE); WriteLn('Testing escape button Keybd input 2 seconds'); KeybdDown(VK_ESCAPE); KeybdUp(VK_ESCAPE); WriteLn('Testing escape button SCAR input 2 seconds'); VKeyDown(VK_ESCAPE); VKeyUp(VK_ESCAPE); end. [/scar] Just try it out and see if it works with your game. Keyboard.dll goes into SCAR's library folder. Tools->Explore->Libraries folder Keyboard.zip Edited October 27, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 27, 2012 Share Posted October 27, 2012 Why not map the direct input constants onto vkeys so you can just input vkeys from SCAR? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 (edited) How do you do that... just be a long case statement i guess..... Edited October 27, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 (edited) EDIT: I got Keybd_event working good! In this game now it successfully sends VK_ESCAPE and does it! I'm going to try it out on some popular game next. Well, I have been testing this, and it actually did something. But I am still struggling to get it to do anything else. For a moment there I got the DirectInput function to hit PrintScreen, somehow, and my game everytime DirectInput ran it said ScreenShot saved, and etc. Here is one of my sources for the code: http://www.delphitricks.com/source-code/windows/simulate_the_pressing_of_keyboard_keys.html Which I still need to look at. I'm probably doing some things wrong. Here is the current plugin code btw: [scar]// Made by LordJashin for SCAR Divi library KeyboardFunctionsGalore; uses System.SysUtils, System.Classes, Winapi.Windows, SCARLibSetup in 'Units\SCARLibSetup.pas', FastShareMem in 'Units\FastShareMem.pas', SCARUtils in 'Units\SCARUtils.pas'; {$R *.res} const DIKEYBOARD_ESCAPE = $0401; DIKEYBOARD_1 = $0402; DIKEYBOARD_2 = $0403; DIKEYBOARD_3 = $0404; DIKEYBOARD_4 = $0405; DIKEYBOARD_5 = $0406; DIKEYBOARD_6 = $0407; DIKEYBOARD_7 = $0408; DIKEYBOARD_8 = $0409; DIKEYBOARD_9 = $040A; DIKEYBOARD_0 = $040B; DIKEYBOARD_MINUS = $040C; // (* - on main keyboard *) DIKEYBOARD_EQUALS = $040D; // DIKEYBOARD_BACK = $040E; // (* backspace *) DIKEYBOARD_TAB = $040F; // DIKEYBOARD_Q = $0410; // DIKEYBOARD_W = $0411; // DIKEYBOARD_E = $0412; // DIKEYBOARD_R = $0413; // DIKEYBOARD_T = $0414; // DIKEYBOARD_Y = $0415; // DIKEYBOARD_U = $0416; // DIKEYBOARD_I = $0417; // DIKEYBOARD_O = $0418; // DIKEYBOARD_P = $0419; // DIKEYBOARD_LBRACKET = $041A; // DIKEYBOARD_RBRACKET = $041B; // DIKEYBOARD_RETURN = $041C; // (* Enter on main keyboard *) DIKEYBOARD_LCONTROL = $041D; // DIKEYBOARD_A = $041E; // DIKEYBOARD_S = $041F; // DIKEYBOARD_D = $0420; // DIKEYBOARD_F = $0421; // DIKEYBOARD_G = $0422; // DIKEYBOARD_H = $0423; // DIKEYBOARD_J = $0424; // DIKEYBOARD_K = $0425; // DIKEYBOARD_L = $0426; // DIKEYBOARD_SEMICOLON = $0427; // DIKEYBOARD_APOSTROPHE = $0428; // DIKEYBOARD_GRAVE = $0429; // (* accent grave *) DIKEYBOARD_LSHIFT = $042A; // DIKEYBOARD_BACKSLASH = $042B; // DIKEYBOARD_Z = $042C; // DIKEYBOARD_X = $042D; // DIKEYBOARD_C = $042E; // DIKEYBOARD_V = $042F; // DIKEYBOARD_B = $0430; // DIKEYBOARD_N = $0431; // DIKEYBOARD_M = $0432; // DIKEYBOARD_COMMA = $0433; // DIKEYBOARD_PERIOD = $0434; // (* . on main keyboard *) DIKEYBOARD_SLASH = $0435; // (* / on main keyboard *) DIKEYBOARD_RSHIFT = $0436; // DIKEYBOARD_MULTIPLY = $0437; // (* * on numeric keypad *) DIKEYBOARD_LMENU = $0438; // (* left Alt *) DIKEYBOARD_SPACE = $0439; // DIKEYBOARD_CAPITAL = $043A; // DIKEYBOARD_F1 = $043B; // DIKEYBOARD_F2 = $043C; // DIKEYBOARD_F3 = $043D; // DIKEYBOARD_F4 = $043E; // DIKEYBOARD_F5 = $043F; // DIKEYBOARD_F6 = $0440; // DIKEYBOARD_F7 = $0441; // DIKEYBOARD_F8 = $0442; // DIKEYBOARD_F9 = $0443; // DIKEYBOARD_F10 = $0444; // DIKEYBOARD_NUMLOCK = $0445; // DIKEYBOARD_SCROLL = $0446; // (* Scroll Lock *) DIKEYBOARD_NUMPAD7 = $0447; // DIKEYBOARD_NUMPAD8 = $0448; // DIKEYBOARD_NUMPAD9 = $0449; // DIKEYBOARD_SUBTRACT = $044A; // (* - on numeric keypad *) DIKEYBOARD_NUMPAD4 = $044B; // DIKEYBOARD_NUMPAD5 = $044C; // DIKEYBOARD_NUMPAD6 = $044D; // DIKEYBOARD_ADD = $044E; // (* + on numeric keypad *) DIKEYBOARD_NUMPAD1 = $044F; // DIKEYBOARD_NUMPAD2 = $0450; // DIKEYBOARD_NUMPAD3 = $0451; // DIKEYBOARD_NUMPAD0 = $0452; // DIKEYBOARD_DECIMAL = $0453; // (* . on numeric keypad *) DIKEYBOARD_OEM_102 = $0456; // (* < > | on UK/Germany keyboards *) DIKEYBOARD_F11 = $0457; // DIKEYBOARD_F12 = $0458; // DIKEYBOARD_F13 = $0464; // (* (NEC PC98) *) DIKEYBOARD_F14 = $0465; // (* (NEC PC98) *) DIKEYBOARD_F15 = $0466; // (* (NEC PC98) *) DIKEYBOARD_KANA = $0470; // (* (Japanese keyboard) *) DIKEYBOARD_ABNT_C1 = $0473; // (* / ? on Portugese (Brazilian) keyboards *) DIKEYBOARD_CONVERT = $0479; // (* (Japanese keyboard) *) DIKEYBOARD_NOCONVERT = $047B; // (* (Japanese keyboard) *) DIKEYBOARD_YEN = $047D; // (* (Japanese keyboard) *) DIKEYBOARD_ABNT_C2 = $047E; // (* Numpad . on Portugese (Brazilian) keyboards *) DIKEYBOARD_NUMPADEQUALS = $048D; // (* = on numeric keypad (NEC PC98) *) DIKEYBOARD_PREVTRACK = $0490; // (* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) *) DIKEYBOARD_AT = $0491; // (* (NEC PC98) *) DIKEYBOARD_COLON = $0492; // (* (NEC PC98) *) DIKEYBOARD_UNDERLINE = $0493; // (* (NEC PC98) *) DIKEYBOARD_KANJI = $0494; // (* (Japanese keyboard) *) DIKEYBOARD_STOP = $0495; // (* (NEC PC98) *) DIKEYBOARD_AX = $0496; // (* (Japan AX) *) DIKEYBOARD_UNLABELED = $0497; // (* (J3100) *) DIKEYBOARD_NEXTTRACK = $0499; // (* Next Track *) DIKEYBOARD_NUMPADENTER = $049C; // (* Enter on numeric keypad *) DIKEYBOARD_RCONTROL = $049D; // DIKEYBOARD_MUTE = $04A0; // (* Mute *) DIKEYBOARD_CALCULATOR = $04A1; // (* Calculator *) DIKEYBOARD_PLAYPAUSE = $04A2; // (* Play / Pause *) DIKEYBOARD_MEDIASTOP = $04A4; // (* Media Stop *) DIKEYBOARD_VOLUMEDOWN = $04AE; // (* Volume - *) DIKEYBOARD_VOLUMEUP = $04B0; // (* Volume + *) DIKEYBOARD_WEBHOME = $04B2; // (* Web home *) DIKEYBOARD_NUMPADCOMMA = $04B3; // (* , on numeric keypad (NEC PC98) *) DIKEYBOARD_DIVIDE = $04B5; // (* / on numeric keypad *) DIKEYBOARD_SYSRQ = $04B7; // DIKEYBOARD_RMENU = $04B8; // (* right Alt *) DIKEYBOARD_PAUSE = $04C5; // (* Pause *) DIKEYBOARD_HOME = $04C7; // (* Home on arrow keypad *) DIKEYBOARD_UP = $04C8; // (* UpArrow on arrow keypad *) DIKEYBOARD_PRIOR = $04C9; // (* PgUp on arrow keypad *) DIKEYBOARD_LEFT = $04CB; // (* LeftArrow on arrow keypad *) DIKEYBOARD_RIGHT = $04CD; // (* RightArrow on arrow keypad *) DIKEYBOARD_END = $04CF; // (* End on arrow keypad *) DIKEYBOARD_DOWN = $04D0; // (* DownArrow on arrow keypad *) DIKEYBOARD_NEXT = $04D1; // (* PgDn on arrow keypad *) DIKEYBOARD_INSERT = $04D2; // (* Insert on arrow keypad *) DIKEYBOARD_DELETE = $04D3; // (* Delete on arrow keypad *) DIKEYBOARD_LWIN = $04DB; // (* Left Windows key *) DIKEYBOARD_RWIN = $04DC; // (* Right Windows key *) DIKEYBOARD_APPS = $04DD; // (* AppMenu key *) DIKEYBOARD_POWER = $04DE; // (* System Power *) DIKEYBOARD_SLEEP = $04DF; // (* System Sleep *) DIKEYBOARD_WAKE = $04E3; // (* System Wake *) DIKEYBOARD_WEBSEARCH = $04E5; // (* Web Search *) DIKEYBOARD_WEBFAVORITES = $04E6; // (* Web Favorites *) DIKEYBOARD_WEBREFRESH = $04E7; // (* Web Refresh *) DIKEYBOARD_WEBSTOP = $04E8; // (* Web Stop *) DIKEYBOARD_WEBFORWARD = $04E9; // (* Web Forward *) DIKEYBOARD_WEBBACK = $04EA; // (* Web Back *) DIKEYBOARD_MYCOMPUTER = $04EB; // (* My Computer *) DIKEYBOARD_MAIL = $04EC; // (* Mail *) DIKEYBOARD_MEDIASELECT = $04ED; // (* Media Select *) const DirectKey: array[0..143] of Cardinal = ( DIKEYBOARD_ESCAPE, DIKEYBOARD_1, DIKEYBOARD_2, DIKEYBOARD_3, DIKEYBOARD_4, DIKEYBOARD_5, DIKEYBOARD_6, DIKEYBOARD_7, DIKEYBOARD_8, DIKEYBOARD_9, DIKEYBOARD_0, DIKEYBOARD_MINUS, DIKEYBOARD_EQUALS, DIKEYBOARD_BACK, DIKEYBOARD_TAB, DIKEYBOARD_Q, DIKEYBOARD_W, DIKEYBOARD_E, DIKEYBOARD_R, DIKEYBOARD_T, DIKEYBOARD_Y, DIKEYBOARD_U, DIKEYBOARD_I, DIKEYBOARD_O, DIKEYBOARD_P, DIKEYBOARD_LBRACKET, DIKEYBOARD_RBRACKET, DIKEYBOARD_RETURN, DIKEYBOARD_LCONTROL, DIKEYBOARD_A, DIKEYBOARD_S, DIKEYBOARD_D, DIKEYBOARD_F, DIKEYBOARD_G, DIKEYBOARD_H, DIKEYBOARD_J, DIKEYBOARD_K, DIKEYBOARD_L, DIKEYBOARD_SEMICOLON, DIKEYBOARD_APOSTROPHE, DIKEYBOARD_GRAVE, DIKEYBOARD_LSHIFT, DIKEYBOARD_BACKSLASH, DIKEYBOARD_Z, DIKEYBOARD_X, DIKEYBOARD_C, DIKEYBOARD_V, DIKEYBOARD_B, DIKEYBOARD_N, DIKEYBOARD_M, DIKEYBOARD_COMMA, DIKEYBOARD_PERIOD, DIKEYBOARD_SLASH, DIKEYBOARD_RSHIFT, DIKEYBOARD_MULTIPLY, DIKEYBOARD_LMENU, DIKEYBOARD_SPACE, DIKEYBOARD_CAPITAL, DIKEYBOARD_F1, DIKEYBOARD_F2, DIKEYBOARD_F3, DIKEYBOARD_F4, DIKEYBOARD_F5, DIKEYBOARD_F6, DIKEYBOARD_F7, DIKEYBOARD_F8, DIKEYBOARD_F9, DIKEYBOARD_F10, DIKEYBOARD_NUMLOCK, DIKEYBOARD_SCROLL, DIKEYBOARD_NUMPAD7, DIKEYBOARD_NUMPAD8, DIKEYBOARD_NUMPAD9, DIKEYBOARD_SUBTRACT, DIKEYBOARD_NUMPAD4, DIKEYBOARD_NUMPAD5, DIKEYBOARD_NUMPAD6, DIKEYBOARD_ADD, DIKEYBOARD_NUMPAD1, DIKEYBOARD_NUMPAD2, DIKEYBOARD_NUMPAD3, DIKEYBOARD_NUMPAD0, DIKEYBOARD_DECIMAL, DIKEYBOARD_OEM_102, DIKEYBOARD_F11, DIKEYBOARD_F12, DIKEYBOARD_F13, DIKEYBOARD_F14, DIKEYBOARD_F15, DIKEYBOARD_KANA, DIKEYBOARD_ABNT_C1, DIKEYBOARD_CONVERT, DIKEYBOARD_NOCONVERT, DIKEYBOARD_YEN, DIKEYBOARD_ABNT_C2, DIKEYBOARD_NUMPADEQUALS, DIKEYBOARD_PREVTRACK, DIKEYBOARD_AT, DIKEYBOARD_COLON, DIKEYBOARD_UNDERLINE, DIKEYBOARD_KANJI, DIKEYBOARD_STOP, DIKEYBOARD_AX, DIKEYBOARD_UNLABELED, DIKEYBOARD_NEXTTRACK, DIKEYBOARD_NUMPADENTER, DIKEYBOARD_RCONTROL, DIKEYBOARD_MUTE, DIKEYBOARD_CALCULATOR, DIKEYBOARD_PLAYPAUSE, DIKEYBOARD_MEDIASTOP, DIKEYBOARD_VOLUMEDOWN, DIKEYBOARD_VOLUMEUP, DIKEYBOARD_WEBHOME, DIKEYBOARD_NUMPADCOMMA, DIKEYBOARD_DIVIDE, DIKEYBOARD_SYSRQ, DIKEYBOARD_RMENU, DIKEYBOARD_PAUSE, DIKEYBOARD_HOME, DIKEYBOARD_UP, DIKEYBOARD_PRIOR, DIKEYBOARD_LEFT, DIKEYBOARD_RIGHT, DIKEYBOARD_END, DIKEYBOARD_DOWN, DIKEYBOARD_NEXT, DIKEYBOARD_INSERT, DIKEYBOARD_DELETE, DIKEYBOARD_LWIN, DIKEYBOARD_RWIN, DIKEYBOARD_APPS, DIKEYBOARD_POWER, DIKEYBOARD_SLEEP, DIKEYBOARD_WAKE, DIKEYBOARD_WEBSEARCH, DIKEYBOARD_WEBFAVORITES, DIKEYBOARD_WEBREFRESH, DIKEYBOARD_WEBSTOP, DIKEYBOARD_WEBFORWARD, DIKEYBOARD_WEBBACK, DIKEYBOARD_MYCOMPUTER, DIKEYBOARD_MAIL, DIKEYBOARD_MEDIASELECT ); function VKeyToDirectScan(VKey: Byte): Byte; var i: Integer; begin Result := 0; for i := 0 to High(DirectKey) do if MapVirtualKey(DirectKey, 1) = VKey then begin Result := DirectKey; Exit; end; end; procedure KeybdDown(VKey: Byte); stdcall; begin keybd_event(VKey, MapvirtualKey(VKey, 0), 0, 0); end; procedure KeybdUp(VKey: Byte); stdcall; begin keybd_event(VKey, MapvirtualKey(VKey, 0), KEYEVENTF_KEYUP, 0); end; function DirectKeyDown(VKey: Byte): Boolean; stdcall; var KeyInputs: array of TInput; KeyInputCount: Integer; procedure KeybdInput(VKey: Byte; Flags: DWORD); begin Inc(KeyInputCount); SetLength(KeyInputs, KeyInputCount); KeyInputs[KeyInputCount - 1].Itype := INPUT_KEYBOARD; with KeyInputs[KeyInputCount - 1].ki do begin wVK := VKey; wScan := VKey; dwFlags := KEYEVENTF_EXTENDEDKEY; dwFlags := Flags or dwFlags; time := 0; dwExtraInfo := 0; end; end; begin Result := False; KeybdInput(VKeyToDirectScan(VKey), 0); if SendInput(KeyInputCount, KeyInputs[0], SizeOf(KeyInputs[0])) > 0 then Result := True; end; function DirectKeyUp(VKey: Byte): Boolean; stdcall; var KeyInputs: array of TInput; KeyInputCount: Integer; procedure KeybdInput(VKey: Byte; Flags: DWORD); begin Inc(KeyInputCount); SetLength(KeyInputs, KeyInputCount); KeyInputs[KeyInputCount - 1].Itype := INPUT_KEYBOARD; with KeyInputs[KeyInputCount - 1].ki do begin wVK := VKey; wScan := VKey; dwFlags := KEYEVENTF_EXTENDEDKEY; dwFlags := Flags or dwFlags; time := 0; dwExtraInfo := 0; end; end; begin Result := False; KeybdInput(VKeyToDirectScan(VKey), KEYEVENTF_KEYUP); if SendInput(KeyInputCount, KeyInputs[0], SizeOf(KeyInputs[0])) > 0 then Result := True; end; procedure OnLoadLib(const SCARExports: PExports); stdcall; begin Exp := SCARExports; // Do NOT remove this line! // Called when the library is loaded end; procedure OnUnloadLib; stdcall; begin // Called when the library is unloaded end; // - Function exports function OnGetFuncCount: Integer; stdcall; begin Result := 4; end; function OnGetFuncInfo(const Idx: Integer; out ProcAddr: Pointer; out ProcDef: PAnsiChar; out CallConv: TCallConv): Integer; stdcall; begin Result := Idx; case Idx of 0: begin ProcAddr := @DirectKeyDown; ProcDef := 'function DirectKeyDown(DIScanCode: Byte): Boolean;'; CallConv := ccStdCall; end; 1: begin ProcAddr := @DirectKeyUp; ProcDef := 'function DirectKeyUp(DIScanCode: Byte): Boolean;'; CallConv := ccStdCall; end; 2: begin ProcAddr := @KeybdDown; ProcDef := 'procedure KeybdDown(VKey: Byte);'; CallConv := ccStdCall; end; 3: begin ProcAddr := @KeybdUp; ProcDef := 'procedure KeybdUp(VKey: Byte);'; CallConv := ccStdCall; end else Result := -1; end; end; // - Type exports function OnGetTypeCount: Integer; stdcall; begin Result := 0; end; function OnGetTypeInfo(const Idx: Integer; out TypeName, TypeDef: PAnsiChar): Integer; stdcall; begin Result := Idx; case Idx of 0: begin {TypeName := 'DIKeyboard'; TypeDef := 'record';} end else Result := -1; end; end; // - Library architecture // Do NOT change this! const LIBRARY_ARCHITECTURE_LEGACY = 1; LIBRARY_ARCHITECTURE_MAIN = 2; function LibArch: Integer; stdcall; begin Result := LIBRARY_ARCHITECTURE_MAIN; end; exports OnLoadLib; exports OnUnloadLib; exports OnGetFuncCount; exports OnGetFuncInfo; exports OnGetTypeCount; exports OnGetTypeInfo; exports LibArch; end.[/scar] DirectInput looks promising but only if it will work right. I don't understand what I am doing wrong yet... EVERY ONE TRY THIS WITH POPULAR games and return your results here!!! Try the KeybdDown and KeybdUp functions! Keyboard.zip Edited October 27, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 (edited) Okay tested this on Vindictus. Got KeybdKeyDown & KeybdKeyUp to: 1. hold the W key down and walk forward on game 2. Press F11 to lay down on ground None of the other functions work just Keybd_event Test file I used: [scar] program New; {$L Keyboardfunctionsgalore.dll} begin GetClient.Activate; //ClickMouse(280, 211, mbleft); wait(2000); WriteLn('Testing directinput 2 seconds'); DirectKeyDown(CharToVkey('W')); DirectKeyUp(CharToVkey('W')); wait(2000); WriteLn('Testing keybd input 2 seconds'); KeybdDown(CharToVKey('w')); wait(2000); KeybdUp(CharToVKey('w')); wait(2000); WriteLn('Testing SCAR input 2 seconds'); VKeyDown(CharToVKey('W')); VKeyUp(CharToVKey('W')); wait(2000); WriteLn('Testing escape button Direct input 2 seconds'); DirectKeyDown(VK_F11); DirectKeyUp(VK_F11); wait(2000); WriteLn('Testing escape button Keybd input 2 seconds'); KeybdDown(VK_F11); KeybdUp(VK_F11); wait(2000); WriteLn('Testing escape button SCAR input 2 seconds'); VKeyDown(VK_F11); VKeyUp(VK_F11); end. [/scar] Edited October 27, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Janilabo Posted October 27, 2012 Share Posted October 27, 2012 Good work, LJ! Giving it a try in 1 game that blocked SCAR's input for me.. I'll report back soon! Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 10-4 I will be updating this severely, testing, and then I'll release the full source and everything in a new thread. And I'll include this in OSI ASAP! Quote Link to comment Share on other sites More sharing options...
LordJashin Posted October 27, 2012 Share Posted October 27, 2012 I'm slowly starting to figure out more about the SendInput API, and it'll be a while before I post the thread. It seems there is more to it than I thought especially if you put a CharToVKey in there. That'll mess it all up. Quote Link to comment Share on other sites More sharing options...