.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   keybd_event (http://forums.bots-united.com/showthread.php?t=4527)

gavin 27-09-2005 20:24

keybd_event
 
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


InternetNightmare 27-09-2005 20:32

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

TIP: MSDN

Rick 27-09-2005 20:34

Re: keybd_event
 
You're not trying to make aimbots eh? :)

edit...I'm slow

gavin 27-09-2005 20:34

Re: keybd_event
 
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

InternetNightmare 27-09-2005 20:41

Re: keybd_event
 
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...)

Rick 27-09-2005 20:45

Re: keybd_event
 
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...)

gavin 27-09-2005 21:09

Re: keybd_event
 
Hi lads.
The only language i know is asm.
The question still stands tho.
Thanks.

Lazy 27-09-2005 21:26

Re: keybd_event
 
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.

gavin 27-09-2005 21:44

Re: keybd_event
 
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.

Lazy 27-09-2005 21:48

Re: keybd_event
 
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.


All times are GMT +2. The time now is 05:24.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.