Jump to content

Can i make this basic script use less resouces


Recommended Posts

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
Link to comment
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
Link to comment
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.
Link to comment
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]
Link to comment
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


            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


kevilay
            
            
                Posted 
                
            
        
    
    
        


kevilay
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 39
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

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

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
    
    

            
        

        

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


kevilay
            
            
                Posted 
                
            
        
    
    
        


kevilay
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 39
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            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
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...