Sign in to follow this  
Followers 0
kevilay

Can i make this basic script use less resouces

10 posts in this topic

Ok is there a way i could redo this to make it use less computer resources cause it lags my computer up. I need to check pixel with loop then because the purpuse is that something movies on the screen and i need script to hit space when it detects the pixel.

HotKeySet("{PAUSE}", "Pause" )
HotKeySet("{f1}", "Driver" )
HotKeySet("{f2}", "Iron" )
HotKeySet("{f3}", "Quit" )

Func Pause()
exit
endfunc

Opt("SendKeyDelay", "1")
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0)

sleep(3000)

While 1
sleep(1)
Wend

Func Driver()
While 1
If PixelGetColor(370, 702) = 10790050 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc


Func Iron()
While 1
If PixelGetColor(372, 695) = 9475986 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc

Func Quit()
Run("Golf Perf")
Exit
EndFunc

Share this post


Link to post
Share on other sites



Ok is there a way i could redo this to make it use less computer resources cause it lags my computer up.

<{POST_SNAPBACK}>

Take the sleep commands out of the if blocks and put them in the while blocks

Share this post


Link to post
Share on other sites

add a few small sleeps ~10/100 in the WHILE loops.

<{POST_SNAPBACK}>

like what do u guys mean by that i dont know could u copy and paste script and change it accoringly plz

Share this post


Link to post
Share on other sites

like what do u guys mean by that i dont know could u copy and paste script and change it accoringly plz

<{POST_SNAPBACK}>

here it is with the sleeps in the while loops.

HotKeySet("{PAUSE}", "Pause" )
HotKeySet("{f1}", "Driver" )
HotKeySet("{f2}", "Iron" )
HotKeySet("{f3}", "Quit" )

Func Pause()
exit
endfunc

Opt("SendKeyDelay", "1")
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0)

sleep(3000)

While 1
sleep(1)
Wend

Func Driver()
While 1
Sleep(100)
If PixelGetColor(370, 702) = 10790050 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc


Func Iron()
While 1
Sleep(100) 
If PixelGetColor(372, 695) = 9475986 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc

Func Quit()
Run("Golf Perf")
Exit
EndFunc

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

problem with that is it check pixel evey 100 ms which isnt fast enough

[quote=SolidSnake,Jun 15 2005, 07:34 PM]
here it is with the sleeps in the while loops.
HotKeySet("{PAUSE}", "Pause" )
HotKeySet("{f1}", "Driver" )
HotKeySet("{f2}", "Iron" )
HotKeySet("{f3}", "Quit" )

Func Pause()
exit
endfunc

Opt("SendKeyDelay", "1")
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0)

sleep(3000)

While 1
sleep(1)
Wend

Func Driver()
While 1
Sleep(100)
If PixelGetColor(370, 702) = 10790050 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc
Func Iron()
While 1
Sleep(100) 
If PixelGetColor(372, 695) = 9475986 then
Send("{space}")
sleep(500)
endif
Wend
EndFunc

Func Quit()
Run("Golf Perf")
Exit
EndFunc
[right][post="86187"][/post][/right]
[/quote]

Share this post


Link to post
Share on other sites

I may be misunderstanding what you're trying to do, but I wasn't sure how the

function keys (Iron and Driver) fit in if you're wanting to loop to check to see

if one of the two pixelcolors shows up. I believe this does the same thing your

code does but you'd only have one place to adjust the Sleep() cycles.

Of course, if both pixelcolors can show up in the two different locations

at the same time then ignore everything I just said...

;

HotKeySet("{PAUSE}", "Pause")HotKeySet("{f3}", "Quit")opt("SendKeyDelay", "1")AutoItSetOption("MouseCoordMode", 0)AutoItSetOption("PixelCoordMode", 0)While 1; This will loop until one of these conditions is true While PixelGetColor(370, 702) <> 10790050 And PixelGetColor(372, 695) <> 9475986        Sleep(50)   WEnd    Send("{Space}") Sleep(500)  ; Does this need to be 500?WEndFunc Pause() ExitEndFunc   ;==>PauseFunc Quit()  Run("Golf Perf")    ExitEndFunc   ;==>Quit


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
kevilay   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                36 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #8 · 
            Posted 
            
            
            
        
    

    


            
        
            I may be  misunderstanding what you're trying to do, but I wasn't sure how thefunction keys (Iron and Driver) fit in if you're wanting to loop to check to see if one of the two pixelcolors shows up.  I believe this does the same thing your code does but you'd only have one place to adjust the Sleep() cycles. Of course, if both pixelcolors can show up in the two different locations at the same time then ignore everything I just said...     ; 

HotKeySet("{PAUSE}", "Pause")

HotKeySet("{f3}", "Quit")

opt("SendKeyDelay", "1")

AutoItSetOption("MouseCoordMode", 0)

AutoItSetOption("PixelCoordMode", 0)

While 1

; This will loop until one of these conditions is true

While PixelGetColor(370, 702) <> 10790050 And PixelGetColor(372, 695) <> 9475986

  Sleep(50)

WEnd

Send("{Space}")

Sleep(500)  ; Does this need to be 500?

WEnd

Func Pause()

Exit

EndFunc  ;==>Pause

Func Quit()

Run("Golf Perf")

Exit

\

EndFunc  ;==>Quit

[post="86198"]<{POST_SNAPBACK}>[/post]

ok i think u are mis understanding , what i want it to do is at the touch of a button search for the pixel ie iron until i hit f3 to stop and restart script so its ready for f command again

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'm assuming that making the loop a function won't work for you either.

If not, sorry I couldn't help. Trying to be creative. I'd done something similar to this with another Pixel function and it seemed to respond a little faster.

;

HotKeySet("{PAUSE}", "Pause")HotKeySet("{f3}", "Quit")HotKeySet("{F2}"),"GoLook")opt("SendKeyDelay", "1")AutoItSetOption("MouseCoordMode", 0)AutoItSetOption("PixelCoordMode", 0)Function GoLook()While 1; This will loop until one of these conditions is trueWhile PixelGetColor(370, 702) <> 10790050 And PixelGetColor(372, 695) <> 9475986  Sleep(50)WEndSend("{Space}")Sleep(500)  ; Does this need to be 500?WEndEndFuncFunc Pause()ExitEndFunc  ;==>PauseFunc Quit()Run("Golf Perf")ExitEndFunc  ;==>Quit


            
                


    Edited  by OldGuyWalking
    
    

            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
kevilay   

    
        
    
             0
    
        
    

        
            
                Seeker
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                36 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #10 · 
            Posted 
            
            
            
        
    

    


            
        
            I'm assuming that making the loop a function won't work for you either. If not, sorry I couldn't help.  Trying to be creative. I'd done something similar to this with another Pixel function and it seemed to respond a little faster.; 

HotKeySet("{PAUSE}", "Pause")

HotKeySet("{f3}", "Quit")

HotKeySet("{F2}"),"GoLook")

opt("SendKeyDelay", "1")

AutoItSetOption("MouseCoordMode", 0)

AutoItSetOption("PixelCoordMode", 0)

Function GoLook()

While 1

; This will loop until one of these conditions is true

While PixelGetColor(370, 702) <> 10790050 And PixelGetColor(372, 695) <> 9475986

  Sleep(50)

WEnd

Send("{Space}")

Sleep(500)  ; Does this need to be 500?

WEnd

EndFunc

Func Pause()

Exit

EndFunc  ;==>Pause

Func Quit()

Run("Golf Perf")

Exit

EndFunc  ;==>Quit

[post="86433"]<{POST_SNAPBACK}>[/post]

see my script works fine the problem is that it lags my computer up so much everything gets slow and everything slows down to the point of unuse

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