Jump to content
tom99

sendinput how?

Recommended Posts

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.

 

SendInput works both with VKeys and scancodes. SCAR's VKey functions use it's VKey functionality, where as the regular char functions send unicode scancodes.

Link to comment
Share on other sites

Okay I think I understand most of it after analyzing it and reading this.

 

The issue with SCAR's Keydown & KeyUp functionality. Is that they use a Char parameter. Instead you could use CharToVKey and have it as a byte parameter. Then we could be sending VKeys as Scancodes, and also send characters as scan codes.

 

Then both would ultimately send characters and Virtual Key codes. With games, they LOVE Scancodes. As shown above, all that I did to make it work was "map" the vkeys to scan codes and send them.

 

I think I will make some new functions regardless though. It said on there that if the input was blocked it would return 0. If that happens we could resort to using PostMessage with the WM_ messages for keys and what not. However I haven't looked at that yet, and that may be more complex than from a glance...

 

 

If they are sent as unicode scancodes then... can't we check if the byte is a character first, and if it ISN'T then leave it as a Vkey?

Using MapVirtualKey, ToUnicode, and w/e functions

 

Like maybe with this? Would VK_F11 return 0 for this?

dsfdsfsdf.png

Edited by LordJashin
Link to comment
Share on other sites

Okay I think I understand most of it after analyzing it and reading this.

 

The issue with SCAR's Keydown & KeyUp functionality. Is that they use a Char parameter. Instead you could use CharToVKey and have it as a byte parameter. Then we could be sending VKeys as Scancodes, and also send characters as scan codes.

 

Then both would ultimately send characters and Virtual Key codes. With games, they LOVE Scancodes. As shown above, all that I did to make it work was "map" the vkeys to scan codes and send them.

 

I think I will make some new functions regardless though. It said on there that if the input was blocked it would return 0. If that happens we could resort to using PostMessage with the WM_ messages for keys and what not. However I haven't looked at that yet, and that may be more complex than from a glance...

 

 

If they are sent as unicode scancodes then... can't we check if the byte is a character first, and if it ISN'T then leave it as a Vkey?

Using MapVirtualKey, ToUnicode, and w/e functions

 

Like maybe with this? Would VK_F11 return 0 for this?

[ATTACH=CONFIG]621[/ATTACH]

 

I know all this... Also, sending window messages is certainly not going to work on games that block input, though this is planned as a reintroduction of silent mouse in SCAR in the near future already, by toggling a currently non-exposed "Silent" property of the TSCARWindowClient. I will considering adding in a way of having SCAR automatically map VKs onto scancodes, but this proved to be too messy to bother with in the past, as in, offering both options. I will have to make it another property then.

Link to comment
Share on other sites

Well I am stumped right now on how to check if its a char or not. I tried ToUnicode. I think i need to do some things differently. But does this look right, or am I doing it all wrong?

 

[scar]

function SetupKeyInput(VKey: Byte; Flags: DWORD): TInput;

var

pp: array[0..2] of WideChar;

T: TKeyboardState;

begin

Result.Itype := INPUT_KEYBOARD;

GetKeyboardState(T);

if (ToUnicode(VKey, MapVirtualKey(VKey, MAPVK_VK_TO_VSC_EX), T, pp, 2, 0) > 0) then

Result.ki.wScan := MapVirtualKey(VKey, MAPVK_VK_TO_CHAR)

else

Result.ki.wScan := MapVirtualKey(VKey, MAPVK_VK_TO_VSC_EX);

with Result.ki do

begin

dwFlags := Flags;

time := 0;

dwExtraInfo := 0;

end;

end;

[/scar]

 

For this plugin guys, it only works with VIRTUAL Key Codes. But for characters e.g. 'a'. I haven't been able to get it to work...

whether I do or not eventually I will post a thread with the plugin just so people can use the Vk codes with games, because I know all too well that having some keyboard functions that do work on it but others that don't. Can be trouble some when scripting...

Link to comment
Share on other sites

Well I have it so virtual keys work just fine! The built in ones do anyway. But as for CharToVKey none of that stuff works. So what would I do to get that to work? How can I check that the VKey is a Character so that I can use the MAP_ToChar flag instead of MAPVK_ToVSC flag?

 

If it doesn't have the ToChar it still doesn't work so Idk what to do here...

 

And as for whats ansi with SCAR and what needs to be unicode or w/e i have no idea lol

Link to comment
Share on other sites

I know all this... Also, sending window messages is certainly not going to work on games that block input, though this is planned as a reintroduction of silent mouse in SCAR in the near future already, by toggling a currently non-exposed "Silent" property of the TSCARWindowClient. I will considering adding in a way of having SCAR automatically map VKs onto scancodes, but this proved to be too messy to bother with in the past, as in, offering both options. I will have to make it another property then.

cant wait, i will be botting in gw like mad :D

Link to comment
Share on other sites

Also Freddy, would the Block Input block WM_CHAR messages? Or WM_SysChar. I mean how would it block the messages, I remember reading this in msdn about sendinput:

 

"To block keyboard and mouse input events from reaching applications, use BlockInput. Note, the BlockInput function will not interfere with the asynchronous keyboard input-state table. This means that calling the SendInput function while input is blocked will change the asynchronous keyboard input-state table."

 

How do I check if the VKey is a character? Why is CharToVKey as a param not sending a Character when using send input with the scan codes?

Edited by LordJashin
Link to comment
Share on other sites

Also Freddy, would the Block Input block WM_CHAR messages? Or WM_SysChar. I mean how would it block the messages, I remember reading this in msdn about sendinput:

 

 

 

How do I check if the VKey is a character? Why is CharToVKey as a param not sending a Character when using send input with the scan codes?

 

There's more than 1 way to block fake input events. Seems pretty straight-forward how to check that, just compare it to some ranges of VK's you know to be chars? I have idea what you mean with that last thing...

Link to comment
Share on other sites

There's more than 1 way to block fake input events. Seems pretty straight-forward how to check that, just compare it to some ranges of VK's you know to be chars? I have idea what you mean with that last thing...

 

W/e I can just wait for you to do it with SCAR. Especially the silent input sounds fantastic xD!

 

But I'll go make a thread with the final library, info, and it will just be for using Vkeys. So no chars will work. But the Vkeys will work, and have for most games by translating them to scancodes with MapVirtualKey...

 

and include it in osi....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...