The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
June 04, 2023, 10:30:50 AM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Campus
| | |-+  SendInput
« previous next »
Pages: 1 [2] Print
Author Topic: SendInput  (Read 18352 times)
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: SendInput
« Reply #15 on: May 02, 2011, 01:51:49 AM »

It was worth a try, but in my code "word ptr VK_NUMLOCK" was accepted but did not correct the problem with the order of the structures in the union.

Logged

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #16 on: May 02, 2011, 02:16:38 AM »

this assembles without error
Code:
        .NOLIST
        .XCREF
        INCLUDE \masm32\include\masm32rt.inc
        .586
        .LIST

;---------------------------------

MOUSEINPUT    STRUCT    ;24 bytes
  _dx         dd ?
  _dy         dd ?
  mouseData   dd ?
  dwFlags     dd ?
  time        dd ?
  dwExtraInfo dd ?
MOUSEINPUT    ENDS

KEYBDINPUT    STRUCT    ;16 bytes
  wVk         dw ?
  wScan       dw ?
  dwFlags     dd ?
  time        dd ?
  dwExtraInfo dd ?
KEYBDINPUT    ENDS

HARDWAREINPUT STRUCT    ;8 bytes
  uMsg        dd ?
  wParamL     dw ?
  wParamH     dw ?
HARDWAREINPUT ENDS

INPUT         STRUCT    ;28 bytes
  dwType      dd ?
  UNION
    mi MOUSEINPUT    <>
    ki KEYBDINPUT    <>
    hi HARDWAREINPUT <>
  ENDS
INPUT         ENDS

;---------------------------------

        .DATA

kia LABEL INPUT
dd INPUT_KEYBOARD                         ;dwType, control key down
dw VK_CONTROL                             ;wVk = VK_CONTROL
dw 0                                      ;wScan
dd 0                                      ;dwFlags = key down
dd 0                                      ;time
dd 0                                      ;dwExtraInfo
dd 0,0                                    ;pad

dd INPUT_KEYBOARD                         ;dwType, "g" key down
dw 0                                      ;wVk
dw 47h                                    ;wScan = "g"
dd KEYEVENTF_SCANCODE                     ;dwFlags = key down
dd 0                                      ;time
dd 0                                      ;dwExtraInfo
dd 0,0                                    ;pad

dd INPUT_KEYBOARD                         ;dwType, "g" key up
dw 0                                      ;wVk
dw 47h                                    ;wScan = "g"
dd KEYEVENTF_SCANCODE or KEYEVENTF_KEYUP  ;dwFlags = key up
dd 0                                      ;time
dd 0                                      ;dwExtraInfo
dd 0,0                                    ;pad

dd INPUT_KEYBOARD                         ;dwType, control key up
dw VK_CONTROL                             ;wVk = VK_CONTROL
dw 0                                      ;wScan
dd KEYEVENTF_KEYUP                        ;dwFlags = key up
dd 0                                      ;time
dd 0                                      ;dwExtraInfo
dd 0,0                                    ;pad

        .CODE

_main   PROC

;        INVOKE  SetFocus,hWin
        INVOKE  SendInput,4,offset kia,sizeof INPUT
        INVOKE  ExitProcess,0

_main   ENDP

        END     _main

now, to put it in a test program   Tongue
Logged
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #17 on: May 02, 2011, 02:32:42 AM »

 BigGrin


if you make another structure array for extended keys, i think you can use the same two arrays to synthesize any key entry

which brings up another point...
don't write code that assumes the user can only type 200 wpm   lol
Logged
ragdog
Member
*****
Posts: 1008


Re: SendInput
« Reply #18 on: May 02, 2011, 10:04:29 AM »

Thanks @all

@dedndave

What if this for a tool os info Dump?
Logged
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #19 on: May 02, 2011, 10:36:12 AM »

it's a project i have been working on for some time
i am updating my OS Info Dump program - here is the old one.....
http://www.masm32.com/board/index.php?topic=11963.msg90835#msg90835
that was a console app

i wanted to learn GUI programming, so this is fancier than it needs to be for OS Info   Tongue
i am almost ready to post the OS Info Dump 3.0 - a few things to fix
i will post the source code when i do
along the way, i wanted to learn about windows messages, so i wrote some code that will display WM messages
i just happened to have it set up like that, so it was easy to add the SendInput code for testing

i have a future project in mind that i can use the GUI text window for   BigGrin
Logged
ragdog
Member
*****
Posts: 1008


Re: SendInput
« Reply #20 on: May 02, 2011, 11:46:07 AM »

Nice tool

I have already your old os dump
But i see you can look with your new version on windows messages ThumbsUp

Ok i wait if you upload your new version

Greate Job
Logged
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #21 on: May 02, 2011, 03:26:13 PM »

that really isn't part of the OS Info program - lol
i added that in as an include file so that i could learn about windows messages
http://www.masm32.com/board/index.php?topic=16460.msg137899#msg137899

i have a few things to fix before i post the OS Info program
but, if you want a program to view messages, Winspector is much more robust
http://www.softpedia.com/get/Security/Security-Related/Winspector.shtml
Logged
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #22 on: May 02, 2011, 04:02:15 PM »

well - it looks like the code still needs a little work
i added WM_CHAR to the message filter
then, ran the program again - no WM_CHAR message   redface



lines 1-4 represent the programatic keystroke using SendInput
lines 5-9 represent the manual keystroke sequence
i don't understand why it generates a "G" when i pressed "g" - caps lock is off   BigGrin
Logged
dedndave
Member
*****
Posts: 12523


Re: SendInput
« Reply #23 on: May 02, 2011, 04:33:54 PM »

if the "right" way doesn't work, cheat   BigGrin



Code:
        .DATA

KyTable dd WM_KEYDOWN,VK_CONTROL,1D0001h
        dd WM_KEYDOWN,'G',220001h
        dd WM_CHAR,7,220001h
        dd WM_KEYUP,'G',0C0220001h
        dd WM_KEYUP,VK_CONTROL,0C01D0001h

        .CODE

        push    ebx
        push    esi
        push    edi
        mov     ebx,hWin
        push    5
        INVOKE  SetFocus,ebx
        mov     edi,offset KyTable
        pop     esi

kLoop0: INVOKE  SendMessage,ebx,[edi],[edi+4],[edi+8]
        add     edi,12
        dec     esi
        jnz     kLoop0

        pop     edi
        pop     esi
        pop     ebx

of course, that does not go through the systems' key filter
it does not generate a Bell character
you might try sending chr$(7), or.....
Code:
        INVOKE  Beep,1000,100
BigGrin
Logged
Pages: 1 [2] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!