[SNIPPET] Send KeyPress

:keyPress
// 0@ - key, 1@ - time
// Example: 0AB1: call @keyPress 2 key 0@ time 1@

if 0AA2: 2@ = load_library "User32.dll"
then
    if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
    then
        0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
        wait 1@
        0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
    end
end
0AB2: ret 0
 

YLess

Member
Joined
Jan 31, 2014
Messages
6
Reaction score
0
Re: Send KeyPress

And this does.. o_O
It sends keystroke, but keybd_event function has been superseded. Use SendInput instead.
 

PopandaulX

Active member
Joined
Jul 15, 2013
Messages
189
Reaction score
1
Re: Send KeyPress

I'm pretty sure Springfield wrote this...
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Or this little different , but same method. Here i used virtual key codes.

[shcode=cpp]
Explane:
0AB1: @FAKE_KEYPRESS 1 _OFFSET_KEY_ 0x44 {A}


/// Snippet
:FAKE_KEYPRESS
if 0AA2: 2@ = load_library "User32.dll"
then
   if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
   then
       0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
       wait 1@
       0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
   end
end
0AB2: ret 0
[/shcode]


Virtual key codes


Offset        Slot    
+ 0x0        Right                        
+ 0x1        Left                            
+ 0x2        Backwards                    
+ 0x3        Forward                        
+ 0x4        Look right                    
+ 0x5        Look left                    
+ 0x6        Look down                        
+ 0x7        Look up                            
+ 0x8        Action            
+ 0xA        Previous weapon/target                
+ 0xC        Aim weapon                    
+ 0xE        Next weapon/target                
+ 0x10        Group CTRL forward                    
+ 0x12        Group CTRL back                        
+ 0x14        Conversation - NO                    
+ 0x16        Conversation - YES                    
+ 0x1A        Change camera                    
+ 0x1C        Jump                            
+ 0x1E        Enter+exit                        
+ 0x20        Sprint                            
+ 0x22        Fire                            
+ 0x24        Crouch                            
+ 0x26        Look behind                        
+ 0x28        Unused                            
+ 0x2A        Walk                            

and more ....
https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
Opcode.eXe said:
:keyPress
// 0@ - key, 1@ - time
// Example: 0AB1: call @keyPress 2 key 0@ time 1@

if 0AA2: 2@ = load_library "User32.dll"
then
    if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
    then
        0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
        wait 1@
        0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
    end
end
0AB2: ret 0

is posible to make this func to send the key via the current thread(or gta/samp idk how can i call it) that have been activated?
what i mean is that i want to send fake keys w/ 3GTAs simulantly (anti pause func on)
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
doroftel said:
Opcode.eXe said:
:keyPress
// 0@ - key, 1@ - time
// Example: 0AB1: call @keyPress 2 key 0@ time 1@

if 0AA2: 2@ = load_library "User32.dll"
then
     if 0AA4: 2@ = get_proc_address "keybd_event" library 2@
     then
         0AA5: call 2@ num_params 4 pop 0 0 0 0 0@
         wait 1@
         0AA5: call 2@ num_params 4 pop 0 0 0x02 0 0@
     end
end
0AB2: ret 0

is posible to make this func to send the key via the current thread(or gta/samp idk how can i call it) that have been activated?
what i mean is that i want to send fake keys w/ 3GTAs simulantly (anti pause func on)

You can use this two memory.
GTA/ SA:MP

PHP:
    0A8C: write_memory 747FB6 size 1 value 1 virtual_protect 1
    0A8C: write_memory 74805A size 1 value 1 virtual_protect 1
 
Top