Thread: keybd_event
View Single Post
keybd_event
Old
  (#1)
gavin
Member
 
Status: Offline
Posts: 6
Join Date: Sep 2005
Default keybd_event - 27-09-2005

Hi lads.

I'm making a simple bot and have the mouse working fine.

The problem i'm having is using keybd_event .
How can i send commands like move jump etc.
Do i have to send them directly to the console ?

I'm also wondering how to i open the console as the if i send the virtual keys for ~ it won't work maybe because of the regional codes?

Thanks

My code is as follows..

Code:
.DATA								  ; initialized data



cs_window db "Counter-Strike",0	 ;the window we want
class db 'Valve001',0			   ;window class

; -------------------------------------------------------------------------
;Other Data section
; -------------------------------------------------------------------------
.DATA?								 
csHandle dd ?				 ;buff for handle on our window
mywindow dd ?				 ;buff on handle to window we want
temphandle dd ?
; -------------------------------------------------------------------------
;Code section
; -------------------------------------------------------------------------
.CODE				


start:					   ;module entry point
   

	invoke FindWindow,	   ;Get handle to the window we want to send input to
	addr class,				
	addr cs_window	   

	cmp eax,0
	je finish
	mov csHandle,eax		 ;put handle here for later on
  
  
	invoke ShowWindow,	   ;make our game window show
	csHandle,
	SW_RESTORE
   
	invoke SetForegroundWindow,  ;make it our default
	csHandle
   
	invoke  Sleep,150		 ;give it a chance
	invoke  Sleep,150		 ;just in case ;)

	invoke EnableWindow,	  ;make it the window to accept input
	csHandle,
	TRUE



	invoke keybd_event,0a1h,0,0,0

	invoke keybd_event,0C0h,0,0,0


	invoke Sleep,1000
  
	invoke keybd_event,0a1h,KEYEVENTF_KEYUP,0,0
	invoke keybd_event,0C0h,KEYEVENTF_KEYUP,0,0
 


;loop_top:

   ; invoke mouse_event,	   
   ; MOUSEEVENTF_MOVE,	 
   ; NULL,				 ;x-axis
  ;  -10,				;y-axis
  ;  NULL,
  ;  NULL
	 

;invoke Sleep,1

   ; invoke mouse_event,
   ; MOUSEEVENTF_MOVE,
   ; NULL,
   ; 10,
   ; NULL,
   ; NULL

;invoke Sleep,1

;jmp loop_top

finish:

invoke ExitProcess,NULL		 ;return to windows
end start
  
Reply With Quote