Jump to content
Sign in to follow this  
AvE

High CPU Usage

Recommended Posts

AvE

Hello everyone. I've just started to write simple bots in AutoIt. I've made a simple program which lets you do bunny-hop in Counter-Strike. My problem is, when someone use the program, CPU Usage is about 50%. How can I fix it?

There's the code of my program.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

WinSetTitle("Counter-Strike","","Counter-Strike [CS Auto-BunnyHop by AvE]")

$NumerOfJumpes = IniRead("CS_Auto-BunnyHop.ini","Settings","$NumberOfJumpes",15)
$Delay = IniRead("CS_Auto-BunnyHop.ini","Settings","$Delay",100)

$Form1 = GUICreate("CS Auto-BunnyHop v0.1", 238, 345, -1, -1)
$Pic1 = GUICtrlCreatePic("bunny11.jpg", 0, 0, 236, 188, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("CS Auto-BunnyHop", 64, 200, 112, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Version: 0.1", 88, 216, 60, 17)
$Label3 = GUICtrlCreateLabel("VAC Proof:", 64, 248, 66, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Group1 = GUICtrlCreateGroup("", 0, 184, 233, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label4 = GUICtrlCreateLabel("4EVER", 128, 248, 44, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("Programmed by AvE.", 64, 272, 103, 17)
$Label6 = GUICtrlCreateLabel("My Steam:", 64, 296, 54, 17)
$Label7 = GUICtrlCreateLabel("pro885", 120, 296, 43, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("HAPPY BUNNYHOPPING!", 40, 320, 152, 17)
GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")

IniWrite("CS_Auto-BunnyHop.ini","Settings","$NumberOfJumpes",$NumerOfJumpes)
IniWrite("CS_Auto-BunnyHop.ini","Settings","$Delay",$Delay)

GUISetState(@SW_SHOW)

While 1
    If _IsPressed(4) Then
        Jump()
    EndIf
WEnd

Func _IsPressed($hexKey)
    $hexKey = DllCall("user32", "int", "GetAsyncKeyState", "int", '0x' & $hexKey)
    If Not @error And BitAND($hexKey[0], 0x8000) = 0x8000 Then Return True
    Return False
EndFunc

Func Jump()
    Send("{SPACE $NumerOfJumpes}")
    Sleep($Delay)
EndFunc

Share this post


Link to post
Share on other sites
water

You have a very tight loop that needs a Sleep to reduce CPU usage:

While 1
    If _IsPressed(4) Then
        Jump()
    EndIf
    Sleep(100)
WEnd


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.