flat assembler
Message board for the users of flat assembler.
Index
> Windows > sendinput to keyboard |
Author |
|
baldr 09 Jun 2014, 01:05
plaster90,
How DWORD type; can be converted to type db 1? By your definition sizeofstruct==0. Even if you place it below ip INPUT line, all-types-fit-in-byte definition won't get you right size. plaster90 wrote: I couldnt sleep because of it |
|||
09 Jun 2014, 01:05 |
|
plaster90 09 Jun 2014, 06:16
all right but could you give me some working example ?
I would be grateful |
|||
09 Jun 2014, 06:16 |
|
baldr 09 Jun 2014, 08:05
plaster90,
This works for me: Code: include "Win32AX.Inc" struct MOUSEINPUT dx dd ? dy dd ? mouseData dd ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct KEYBDINPUT wVk dw ? wScan dw ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct HARDWAREINPUT uMsg dd ? wParamL dw ? wParamH dw ? ends struct INPUT type dd ? union ki KEYBDINPUT mi MOUSEINPUT hi HARDWAREINPUT ends ends INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 INPUT_HARDWARE = 2 KEYEVENTF_EXTENDEDKEY = 1 KEYEVENTF_KEYUP = 2 KEYEVENTF_UNICODE = 4 KEYEVENTF_SCANCODE = 8 .code start: invoke SendInput, lengthof.inputs, inputs, sizeof.INPUT invoke ExitProcess, 0 .data inputs: irps vk, B A L D R { INPUT INPUT_KEYBOARD, <`vk, 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <`vk, 0, KEYEVENTF_KEYUP, 0, 0> } lengthof.inputs = ($-inputs)/sizeof.INPUT .end start |
|||
09 Jun 2014, 08:05 |
|
plaster90 09 Jun 2014, 08:20
thx a lot:)
|
|||
09 Jun 2014, 08:20 |
|
randomdude 09 Jun 2014, 08:53
dont forget that if you use:
Code: struct INPUT type dd ? union mi MOUSEINPUT ki KEYBDINPUT hi HARDWAREINPUT ends ends all values will be passed as DWORDs Code: INPUT INPUT_KEYBOARD, <wVk + wScan shl 16, 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <wVk + wScan shl 16, KEYEVENTF_KEYUP, 0, 0> |
|||
09 Jun 2014, 08:53 |
|
plaster90 09 Jun 2014, 09:16
baldr
works good, but is there a way to dont use macro? i'm not professional, i'm going to learn macros but this is very hard for me:( i would be gratefull if you give me this cod witout macros thanks a lot |
|||
09 Jun 2014, 09:16 |
|
baldr 09 Jun 2014, 09:41
plaster90,
That irps instant macro expands as a sequence of INPUT …,<character,…> / INPUT …,<character, 0, KEYEVENTF_KEYUP,…> pairs for each given letter: Code: INPUT INPUT_KEYBOARD, <'B', 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <'B', 0, KEYEVENTF_KEYUP, 0, 0> INPUT INPUT_KEYBOARD, <'A', 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <'A', 0, KEYEVENTF_KEYUP, 0, 0> INPUT INPUT_KEYBOARD, <'L', 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <'L', 0, KEYEVENTF_KEYUP, 0, 0> INPUT INPUT_KEYBOARD, <'D', 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <'D', 0, KEYEVENTF_KEYUP, 0, 0> INPUT INPUT_KEYBOARD, <'R', 0, 0, 0, 0> INPUT INPUT_KEYBOARD, <'R', 0, KEYEVENTF_KEYUP, 0, 0> |
|||
09 Jun 2014, 09:41 |
|
plaster90 09 Jun 2014, 11:17
now it's clear:)
thanks |
|||
09 Jun 2014, 11:17 |
|
plaster90 11 Jun 2014, 23:11
Hi i got code to past some tekst but it doesn't fully works:(
Code: format PE GUI 4.0 entry start include 'include\win32ax.inc' struct MOUSEINPUT dx dd ? dy dd ? mouseData dd ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct KEYBDINPUT wVk dw ? wScan dw ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct HARDWAREINPUT uMsg dd ? wParamL dw ? wParamH dw ? ends struct INPUT type dd ? union mi MOUSEINPUT ki KEYBDINPUT hi HARDWAREINPUT ends ends start: ;invoke Sleep,7000 invoke SendInput,1, inputs1, sizeof.INPUT invoke SendInput,1, inputs2, sizeof.INPUT invoke SendInput,1, inputs3, sizeof.INPUT invoke SendInput,1, inputs4, sizeof.INPUT koniec: invoke ExitProcess,0 inputs1: INPUT 1, <VK_CONTROL, 0, 0, 0, 0> inputs2: INPUT 1, <'V', 0,0, 0, 0> inputs3: INPUT 3, <'V' 0, KEYEVENTF_KEYUP, 0, 0> inputs4: INPUT 4, <VK_CONTROL, 0,KEYEVENTF_KEYUP, 0, 0> section '.idata' import data readable writeable shareable library kernel32, 'kernel32.DLL',\ user32, 'user32.DLL' include 'include\api\kernel32.inc' include 'include\api\user32.inc' My question is why The program DOESN'T relase the key? it past tekst but CTRL KEY is still press:( |
|||
11 Jun 2014, 23:11 |
|
plaster90 12 Jun 2014, 07:37
Hi i got code to past some tekst but it doesn't fully works:(
Code: format PE GUI 4.0 entry start include 'include\win32ax.inc' struct MOUSEINPUT dx dd ? dy dd ? mouseData dd ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct KEYBDINPUT wVk dw ? wScan dw ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct HARDWAREINPUT uMsg dd ? wParamL dw ? wParamH dw ? ends struct INPUT type dd ? union mi MOUSEINPUT ki KEYBDINPUT hi HARDWAREINPUT ends ends start: ;invoke Sleep,7000 invoke SendInput,1, inputs1, sizeof.INPUT invoke SendInput,1, inputs2, sizeof.INPUT invoke SendInput,1, inputs3, sizeof.INPUT invoke SendInput,1, inputs4, sizeof.INPUT koniec: invoke ExitProcess,0 inputs1: INPUT 1, <VK_CONTROL, 0, 0, 0, 0> inputs2: INPUT 1, <'V', 0,0, 0, 0> inputs3: INPUT 3, <'V' 0, KEYEVENTF_KEYUP, 0, 0> inputs4: INPUT 4, <VK_CONTROL, 0,KEYEVENTF_KEYUP, 0, 0> section '.idata' import data readable writeable shareable library kernel32, 'kernel32.DLL',\ user32, 'user32.DLL' include 'include\api\kernel32.inc' include 'include\api\user32.inc' My question is why The program DOESN'T relase the key?Sad it past tekst but CTRL KEY is still press:( |
|||
12 Jun 2014, 07:37 |
|
baldr 12 Jun 2014, 08:44
plaster90 wrote: Hi i got code to past some tekst but it doesn't fully works:( |
|||
12 Jun 2014, 08:44 |
|
plaster90 12 Jun 2014, 09:42
Sorry baldr. I pasted wrong code. There is
Inputs3: Input 1 (...) Inputs4: Input 1 (...) And i placed mi MOUSEINPUT bufor ki KEYBOARDINPUT because its correct in msdn funkcion. Where did i make a mistake? I'd like to write it exacly as msdn function. Will you help? Last edited by plaster90 on 12 Jun 2014, 09:44; edited 1 time in total |
|||
12 Jun 2014, 09:42 |
|
plaster90 12 Jun 2014, 10:48
Baldr
Just one more question This is your code: Code: struct INPUT type dd ? union ki KEYBDINPUT mi MOUSEINPUT hi HARDWAREINPUT ends ends INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 INPUT_HARDWARE = 2 Could you explain me why you Wrote Code: INPUT_MOUSE = 0 so first position in INPUT's struct is Code: ki KEYBDINPUT ? Sorry but I don't get it:/ I think it should be: Code: ki MOUSEINPUT mi KEYBDINPUT But This code doesnt work good. .. Thanks in advance plaster90 |
|||
12 Jun 2014, 10:48 |
|
baldr 12 Jun 2014, 13:04
plaster90,
The order of the members inside the union usually doesn't matter. In stock fasm macros (Macro/Struct.Inc) there is one caveat: initializer for the union uses definition of its first member, hence if you place mi before ki, values you're providing should correspond to <dx, dy, mouseData, dwFlags, time, dwExtraInfo> respectively. Since KEYBDINPUT starts with two words, wVk and wScan, they map to the single MOUSEINPUT dword, dx (lower and higher 16 bits). Consequently, proper initialization of an INPUT structure with MOUSEINPUT first member within anonymous union should look like INPUT INPUT_KEYBOARD, <wVk+wScan shl 16, dwFlags, time, dwExtraInfo>. Order or values of INPUT_* numerical constants are completely unrelated to that. |
|||
12 Jun 2014, 13:04 |
|
plaster90 12 Jun 2014, 13:21
I must study macros...
If you dont mind, Could give me a the same code sending 'baldr' and then execute MOUSEINPUT for example: Code: invoke SendInput, 1,some, sizeof. INPUT invoke SendInput, 1,some2, sizeof.INPUT (......) some: INPUT 0,<VK_CONTROL, 0,0,0,0,0> some2: INPUT 0,<VK_CONTROL, 0,KEYEVENTF_KEYUP> I would be grateful |
|||
12 Jun 2014, 13:21 |
|
baldr 12 Jun 2014, 14:40
plaster90,
You're either lazy or not understanding what to do. Code: include "Win32AX.Inc" struct MOUSEINPUT dx dd ? dy dd ? mouseData dd ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct KEYBDINPUT wVk dw ? wScan dw ? dwFlags dd ? time dd ? dwExtraInfo dd ? ends struct HARDWAREINPUT uMsg dd ? wParamL dw ? wParamH dw ? ends struct INPUT type dd ? union mi MOUSEINPUT ki KEYBDINPUT hi HARDWAREINPUT ends ends INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 INPUT_HARDWARE = 2 KEYEVENTF_EXTENDEDKEY = 1 KEYEVENTF_KEYUP = 2 KEYEVENTF_UNICODE = 4 KEYEVENTF_SCANCODE = 8 MOUSEEVENTF_MOVE = 1 MOUSEEVENTF_LEFTDOWN = 2 MOUSEEVENTF_LEFTUP = 4 .code start: invoke SendInput, lengthof.inputs, inputs, sizeof.INPUT invoke ExitProcess, 0 .data inputs: INPUT INPUT_KEYBOARD, <'B'> INPUT INPUT_KEYBOARD, <'B', KEYEVENTF_KEYUP> INPUT INPUT_KEYBOARD, <'A'> INPUT INPUT_KEYBOARD, <'A', KEYEVENTF_KEYUP> INPUT INPUT_KEYBOARD, <'L'> INPUT INPUT_KEYBOARD, <'L', KEYEVENTF_KEYUP> INPUT INPUT_KEYBOARD, <'D'> INPUT INPUT_KEYBOARD, <'D', KEYEVENTF_KEYUP> INPUT INPUT_KEYBOARD, <'R'> INPUT INPUT_KEYBOARD, <'R', KEYEVENTF_KEYUP> INPUT INPUT_MOUSE, <0, 0, 0, MOUSEEVENTF_LEFTDOWN> INPUT INPUT_MOUSE, <100, 0, 0, MOUSEEVENTF_MOVE> INPUT INPUT_MOUSE, <0, 0, 0, MOUSEEVENTF_LEFTUP> lengthof.inputs = ($-inputs)/sizeof.INPUT .end start |
|||
12 Jun 2014, 14:40 |
|
plaster90 12 Jun 2014, 15:32
Does anyone know how to send key to keyboard using sendinput funkction, but from this kind of bufor:
Code: bufor dd ? |
|||
12 Jun 2014, 15:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.