Jump to content

High CPU Usage


 Share

Recommended Posts

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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...