.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
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
Re: keybd_event
Old
  (#2)
InternetNightmare
Member
 
Status: Offline
Posts: 5
Join Date: Aug 2005
Default Re: keybd_event - 27-09-2005

Hmmm... I think you're trying to write an aimbot and that's EVIL!
No help here

TIP: MSDN


Knowing a lot is not that good... Doing a lot that's what really maters. Knowing a lot makes others think you're smart, doing a lot makes others respect you!
Love rules the world! Until it's true, we're only human...

Last edited by InternetNightmare; 27-09-2005 at 21:35..
  
Reply With Quote
Re: keybd_event
Old
  (#3)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: keybd_event - 27-09-2005

You're not trying to make aimbots eh?

edit...I'm slow

Last edited by Rick; 27-09-2005 at 21:36..
  
Reply With Quote
Re: keybd_event
Old
  (#4)
gavin
Member
 
Status: Offline
Posts: 6
Join Date: Sep 2005
Default Re: keybd_event - 27-09-2005

It's impossible to write an aimbot by sending data to the window.
Read the api's i'm using and you will see what i'm doing.
Btw an aimbot i assembly are you mad?
Thanks

Last edited by gavin; 27-09-2005 at 21:36..
  
Reply With Quote
Re: keybd_event
Old
  (#5)
InternetNightmare
Member
 
Status: Offline
Posts: 5
Join Date: Aug 2005
Default Re: keybd_event - 27-09-2005

OK, if it's not an aimbot, so what's the point emulating keyboard&mouse for CS? Why not M$ wrod? You could make it write poems

My guess: YOu want to turn on teh bot when you're away so it makes you jump and stuff.

(I think Cheating-Death checks for the stuff like that...)


Knowing a lot is not that good... Doing a lot that's what really maters. Knowing a lot makes others think you're smart, doing a lot makes others respect you!
Love rules the world! Until it's true, we're only human...
  
Reply With Quote
Re: keybd_event
Old
  (#6)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: keybd_event - 27-09-2005

Quote:
Originally Posted by gavin
It's impossible to write an aimbot by sending data to the window.
Read the api's i'm using and you will see what i'm doing.
Btw an aimbot i assembly are you mad?
Thanks
Well...just a suggestion, but wouldn't it be better to make a bot like other people did for CS(using C/C++, Dll hooking and some SDK stuff). Unless you have a strong preference for ASM ofcourse

(And no I'm not mad...)
  
Reply With Quote
Re: keybd_event
Old
  (#7)
gavin
Member
 
Status: Offline
Posts: 6
Join Date: Sep 2005
Default Re: keybd_event - 27-09-2005

Hi lads.
The only language i know is asm.
The question still stands tho.
Thanks.
  
Reply With Quote
Re: keybd_event
Old
  (#8)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: keybd_event - 27-09-2005

What kind of bot are you doing?
I'm just asking because they are _usually_ done server-side and not in a seperate client application.

As for running commands, I doubt you could get console commands running through a second application.
You could send window messages like WM_KEYDOWN, ect to the half-life window which would make the player move or do other things.

The easiest way to do a client-side bot is with a dll hook but since VAC2 is out its not safe to do.

Notice: The only client-side thing I had running was a clock, nothing else... Not only that I started using windowed mode so the clock became useless.
Though I did learn alot about function hooking.

[Added]
Actually, if you somehow managed to get loaded into half-life's address space and remain undetected by VAC2 you could run console commands...

- Hook cl_enginefuncs_t::pfnCmd_Args, pfnCmd_Argc, pfnCmd_Argv
- In you pfnCmd_xxx functions simply return your custom command
- Call pfnClientCommand

I think, haven't touched the client in a long time.

Last edited by Lazy; 27-09-2005 at 22:29..
  
Reply With Quote
Re: keybd_event
Old
  (#9)
gavin
Member
 
Status: Offline
Posts: 6
Join Date: Sep 2005
Default Re: keybd_event - 27-09-2005

Hi Lazy .
Your name contradicts itself
Anyways man my bot is a cup of tea bot

It's all client side.

Here's the basic things i'm doing.

1 Get handle to the cs window.--> FindWindow function
2 Make our game window show --> ShowWindow function
3 Make it the window to accept input --->SetForegroundWindow+EnableWindow

All that is done.
Plus

mouse_event works perfectly.

Now the thing is keybd_event simulates keystrokes right.

window messages like WM_KEYDOWN

Are you referring to the sendmessage function?
Could i have an example please.
Thanks for your time.
  
Reply With Quote
Re: keybd_event
Old
  (#10)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: keybd_event - 27-09-2005

So your bot just moves around randomly so you don't get booted by auto afk kicking plugins?

As for sendmessage, lemme write something up really quick - it will be in C though but I'll comment it to make porting easier.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com