Anybody have any idea why SendInput will not send the same key twice. If I call the procedure SendKeys with the string "hello" I get "helo" but if I call it with "helto" I get "helto". In both cases SendInput returns 5 to indicate that 5 characters were added to the keyboard queue.

KEYBDINPUT struct

dwType DD
wVk DW
wScan DW
dwFlags DD
time DD
dwExtraInfo DD
padding DD 2 DUP (0)
ends

<Code snipped see below>
Posted on 2004-06-22 01:32:33 by donkey
It seems to work OK if I insert a ShiftDown/ShiftUp in between...

<code snipped it wasn't the right way>
Posted on 2004-06-22 01:50:15 by donkey
Here is the MSDN reference for a VB example:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskcodesendingkeystrokestoanotherapplicationvisualbasic.asp

I'm not sure what all you are doing in your function or why, it looks like you have something complicated going on :)

I am guessing debounce of the key or a message not being returned from a dlgbox/window properly, or the display itself.. maybe checking for a flag setting on the window? I am grasping at straws, hope it helps.
Posted on 2004-06-22 02:42:06 by drarem
Hi,

Unfortuantely I know nothing about VB, I wouldn't understand a line of it. I understand what I was doing wrong now, I was sending the key down and not releasing it. I have to send the key up or it will not recognize it as two presses. It is just for a library of interprocess functions I am writing for GoAsm, it will send a string to the keyboard input queue...

invoke SendKeys, "This is a test"

SendKeys FRAME pString

uses esi,edi,ebx
LOCAL pKBinput :D

invoke GlobalAlloc,GMEM_ZEROINIT,32768
mov [pKBinput],eax
mov esi,eax
mov edi,[pString]
xor ebx,ebx

:
mov al,[edi]
inc edi
or al,al
jz >.EXIT
add ebx,2
and eax,0FFh

invoke VkKeyScanA,eax
test eax,100h
jz >N1
; Key is shifted
mov W[esi+KEYBDINPUT.wVk], VK_SHIFT
mov D[esi+KEYBDINPUT.dwType], INPUT_KEYBOARD
add esi,SIZEOF KEYBDINPUT

and eax,0FFh
mov D[esi+KEYBDINPUT.dwType], INPUT_KEYBOARD
mov W[esi+KEYBDINPUT.wVk], ax

add esi,SIZEOF KEYBDINPUT
mov W[esi+KEYBDINPUT.wVk], VK_SHIFT
mov D[esi+KEYBDINPUT.dwType], INPUT_KEYBOARD
mov D[esi+KEYBDINPUT.dwFlags], KEYEVENTF_KEYUP

add esi,SIZEOF KEYBDINPUT
add ebx,1
jmp <
N1:

and eax,0FFh
mov D[esi+KEYBDINPUT.dwType], INPUT_KEYBOARD
mov W[esi+KEYBDINPUT.wVk], ax
add esi, SIZEOF KEYBDINPUT
mov D[esi+KEYBDINPUT.dwType], INPUT_KEYBOARD
mov W[esi+KEYBDINPUT.wVk], ax
mov D[esi+KEYBDINPUT.dwFlags], KEYEVENTF_KEYUP
add esi, SIZEOF KEYBDINPUT
jmp <
.EXIT

invoke SendInput, ebx, [pKBinput], SIZEOF KEYBDINPUT
invoke GlobalFree,[pKBinput]

ret
ENDF
Posted on 2004-06-22 02:54:28 by donkey