Sign in to follow this  
Followers 0
hendrikhe

Why my little script use so much processor capacity??

6 posts in this topic

#1 ·  Posted (edited)

I just wrote a little script, but from time to time (lets say: every 3 min) my computer become really slow for 10 sec.

And that happens only if I turn my script on. I see that the script take about 50% of my processor capacity on the Task Manager. Any ideias?

#Include <Misc.au3>


hotkeyset("!s", "_Start")
hotkeyset("!p", "_Pause")



while 1

sleep(500)  
    
WEnd

Func _Start()


while 1

$dll = DllOpen("user32.dll")

if _IsPressed("45", $dll) Then
    
    while _IsPressed("01", $dll) == 0
    WEnd        
    ControlSend("Heroes of Newerth","","","r")
    $pos = MouseGetPos()
    _MouseClickPlus( "Heroes of Newerth", "left", $pos[0], $pos[1], 1) 
    
    
EndIF

DllClose("user32.dll")

WEnd

EndFunc

Func _Pause() ; pause 
        While 1
        sleep(100)
    WEnd
EndFunc


Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 13)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202
  
  Local $MK_RBUTTON       =  0x0002  
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200
  
  Local $i                = 0
  
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
  
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
  
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
    
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong(512, 421))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Edited by hendrikhe

Share this post


Link to post
Share on other sites



I don't know but there is no way to return from the pause function. Maybe you could have a global variable which is checked in the pause look, and that variable is set in the start function.

The while the left mouse button is not pressed/wend in your start function should have a sleep inside it to prevent it from use too much processor time, but it is difficult to see how you are going to press Alt s and E to get the script to execute that section.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Don't open or close dll's inside a loop. Don't use DllCall with a filename, use a handle....

Share this post


Link to post
Share on other sites

Oh also, this script violates the Heroes of Newarth TOS:

You will violate the Terms of Service if you (or others using your Account) do any of the following:

  • Harass, threaten, embarrass, or do anything else to another Member or guest that is unwanted.
  • Transmit or facilitate distribution of Content that is harmful, abusive, racially or ethnically offensive, vulgar, sexually explicit, defamatory, infringing, invasive of personal privacy or publicity rights, or in a reasonable person's view, objectionable. Hate speech is not tolerated.
  • Impersonate another person (including celebrities), indicate that you are an S2 employee or a representative of S2.
  • Upload any software or Content that you do not own or have permission to freely distribute.
  • Promote or encourage any illegal activity including hacking, cracking or distribution of counterfeit software.
  • Post, transmit, promote, or distribute Content that is illegal.
  • Upload files that contain a virus or corrupted data.
  • Post messages for any purpose other than personal communication, including without limitation advertising, promotional materials, chain letters, pyramid schemes, or make any commercial use of our Service.
  • Use or distribute "auto" software programs, "macro" software programs or other "cheat utility" software program or applications.
  • You must obey all applicable laws, regulations and rules wherever you are on the Service. This includes rules for use of third-party technology and content, rules of interactive service providers, and federal, state, local and foreign laws where applicable. Ignorance of the law is no excuse. The laws that apply in the offline world must be obeyed online as well. We have zero tolerance for illegal behavior on the Service. We will cooperate with law enforcement in such matters.
  • You will not exploit any bug in S2's product to gain unfair advantage in the game and you will not communicate the existence of any such bug (either directly or through the public posting) to any other user of the Service.

Share this post


Link to post
Share on other sites

Yeah but its good to use it on practice server, i remember there were similar macros for dota.

Share this post


Link to post
Share on other sites

What is your script doing, anyway :mellow:? Quickly clicking on some position?

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  
Followers 0