Jump to content

Need Help with Funcs


Rawox
 Share

Recommended Posts

Hey,

Does anyone know why this script isn't working, I tried everything I could think of but couldn't find it....

; ============= OPTIONS ==============

HotKeySet("{F4}", "ExitProg")
#NoTrayIcon
Opt("WinTitleMatchMode", 2)

; ============== VARIABLES ==============

Global $iColor = 0xd6ded4

; ============== FUNCTIONS ==============

Restart1 ()
Restart2 ()
Restart3 ()

; ============== SCRIPT ==============

ShellExecute ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
WinWaitActive ( "Firefox" )
Sleep ( 1000 )
Send ( "{F6}" )
Sleep ( 100 )
Send ( "deviantart.com ^{ENTER}" )
WinWaitActive ( "DeviantART" )
Sleep ( 2500 )

PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
If Not @error Then
      MsgBox ( 0, "Good News!", "Color was found!" )
EndIf
If @error Then
    Func Restart1()
EndIf

; ============== FUNCTIONS ==============

Func ExitProg()
    Exit
EndFunc

Func Restart1()
        Sleep ( 2500 )
        PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
    If Not @error Then
        MsgBox ( 0, "Good News!", "Color was found While Searching Twice!" )
EndIf
If @error Then
        Func Restart2()
EndIf
EndFunc

Func Restart2()
        Sleep ( 2500 )
        PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
    If Not @error Then
        MsgBox ( 0, "Good News!", "Color was found While Searching For the Third Time!" )
EndIf
If @error Then
        MsgBox ( 0, "Error", "Error, please restart the script" )
EndIf
EndFunc
Link to comment
Share on other sites

Hey,

Does anyone know why this script isn't working, I tried everything I could think of but couldn't find it....

; ============= OPTIONS ==============

HotKeySet("{F4}", "ExitProg")
#NoTrayIcon
Opt("WinTitleMatchMode", 2)

; ============== VARIABLES ==============

Global $iColor = 0xd6ded4

; ============== FUNCTIONS ==============

Restart1 ()
Restart2 ()
Restart3 ()

; ============== SCRIPT ==============

ShellExecute ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
WinWaitActive ( "Firefox" )
Sleep ( 1000 )
Send ( "{F6}" )
Sleep ( 100 )
Send ( "deviantart.com ^{ENTER}" )
WinWaitActive ( "DeviantART" )
Sleep ( 2500 )

PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
If Not @error Then
      MsgBox ( 0, "Good News!", "Color was found!" )
EndIf
If @error Then
    Func Restart1()
EndIf

; ============== FUNCTIONS ==============

Func ExitProg()
    Exit
EndFunc

Func Restart1()
        Sleep ( 2500 )
        PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
    If Not @error Then
        MsgBox ( 0, "Good News!", "Color was found While Searching Twice!" )
EndIf
If @error Then
        Func Restart2()
EndIf
EndFunc

Func Restart2()
        Sleep ( 2500 )
        PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
    If Not @error Then
        MsgBox ( 0, "Good News!", "Color was found While Searching For the Third Time!" )
EndIf
If @error Then
        MsgBox ( 0, "Error", "Error, please restart the script" )
EndIf
EndFunc
If youre calling a function, you just need to write:

Restart1()oÝ÷ Ø  ÝÜ"W[ay¬µªíÕû§rب©l¢+fk)èµ·¦ºéºÜ!z·²¢èZ½ëaxDQ9ý²%vâßÙeºÇ¨êÊ«±«ìZ^jëh×6PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
If Not @error Then
      MsgBox ( 0, "Good News!", "Color was found!" )
EndIf
If @error Then
    Func Restart1()
EndIf

;YOU WANT THIS INSTEAD

PixelSearch ( 0, 0, 600, 600, $iColor, 0 )
If @error Then
    Restart1()
Else
      MsgBox ( 0, "Good News!", "Color was found!" )
EndIf
Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

When you call a function you must no have the Func keyword in front of it. This will make AutoI think you are trying to create a new function with the same name so it throws an error

For example

If @error Then
    Func Restart1()
EndIfoÝ÷ Ù(hºW[zX¤z¬jëh×6If @error Then
    Restart1()
EndIf

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Owkey! I do now have this, the problem now is that the pop-ups never show up... :) Anyone??

; ============= OPTIONS ==============

HotKeySet("{F4}", "ExitProg")
;#NoTrayIcon
Opt("WinTitleMatchMode", 2)

; ============== VARIABLES ==============

Global $iColor = 0xd6ded4

; ============== FUNCTIONS ==============

;Restart1 ()
;Restart2 ()
;Restart3 ()

; ============== SCRIPT ==============

ShellExecute ( "C:\Program Files\Mozilla Firefox\firefox.exe" )
WinWaitActive ( "Firefox" )
Sleep ( 1000 )
Send ( "{F6}" )
Sleep ( 100 )
Send ( "deviantart.com ^{ENTER}" )
WinWaitActive ( "DeviantART" )

Sleep ( 2500 )
PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

If @error Then
    Restart1()
Else
    MsgBox ( 0, "Good News!", "Color was found!" )
EndIf

; ============== FUNCTIONS ==============

Func ExitProg()
    Exit
EndFunc

Func Restart1()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        Restart2()
    Else
        MsgBox ( 0, "Good News!", "Color was found 2nd Time!" )
    EndIf
EndFunc

Func Restart2()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        MsgBox ( 0, "Error!", "Error" )
    Else
        MsgBox ( 0, "Good News!", "Color was found 3th Time!" )
    EndIf
EndFunc
Link to comment
Share on other sites

No, I don't want to use includes etc. :) Why doesn't it work?

I just ran your script and can see a few things. First, what are you trying to do by sending a F6 key to firefox? Second, how are you getting the url in the location field.

--------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: [post="635594"]Multiple Monitor Screen Resolution Change[/post]

Link to comment
Share on other sites

I got it working with a few changes, I commented the changed lines.


HotKeySet("{F4}", "ExitProg")
;#NoTrayIcon
Opt("WinTitleMatchMode", 2)

; ============== VARIABLES ==============

Global $iColor = 0xd6ded4

; ============== FUNCTIONS ==============

;Restart1 ()
;Restart2 ()
;Restart3 ()

; ============== SCRIPT ==============

ShellExecute ( "d:\Program Files\Mozilla Firefox\firefox.exe" )
WinWaitActive ( "Firefox" )
Sleep ( 1000 )
;Send ( "{F6}" ) ;commented out this line
Sleep ( 100 )
Send ( "deviantart.com {ENTER}" )  ; removed the ^6
WinWaitActive ( "deviantART" ) ; Changed titles case

Sleep ( 2500 )
PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

If @error Then
    Restart1()
Else
    MsgBox ( 0, "Good News!", "Color was found!" )
EndIf

; ============== FUNCTIONS ==============

Func ExitProg()
    Exit
EndFunc

Func Restart1()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        Restart2()
    Else
        MsgBox ( 0, "Good News!", "Color was found 2nd Time!" )
    EndIf
EndFunc

Func Restart2()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        MsgBox ( 0, "Error!", "Error" )
    Else
        MsgBox ( 0, "Good News!", "Color was found 3th Time!" )
    EndIf
EndFunc
[code/]

Bob


            
        

        

        
            

    
        

        
            --------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: [post="635594"]Multiple Monitor Screen Resolution Change[/post]
        
    

        
    

    

    




    Link to comment
    
        
    
    
    

    
    Share on other sites
    

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    


    
    More sharing options...

    


    

                    
                    
                    
                

                    

                    
                    





    

    

    
        
            
                


    
        
    

                
                
                    
                        

                    
                
            
        
        
            
                


Rawox
            
            
                Posted 
                
            
        
    
    
        


Rawox
            
        
        
            
                
                    


    
        
    

                    
                    
                        

                    
                
            
            
                Active Members
                
            
            
                
                    
                        
                            
                                
                            
                                 318
                            
                                
                            
                        
                        
                    
                
            
            
                

            
        
    
    
        



    
        
            
                
                    
                        Author
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted 
            
            
                
                
            
        
    

    

    

    
        
        
            
I got it working with a few changes, I commented the changed lines.

HotKeySet("{F4}", "ExitProg")
;#NoTrayIcon
Opt("WinTitleMatchMode", 2)

; ============== VARIABLES ==============

Global $iColor = 0xd6ded4

; ============== FUNCTIONS ==============

;Restart1 ()
;Restart2 ()
;Restart3 ()

; ============== SCRIPT ==============

ShellExecute ( "d:\Program Files\Mozilla Firefox\firefox.exe" )
WinWaitActive ( "Firefox" )
Sleep ( 1000 )
;Send ( "{F6}" );commented out this line
Sleep ( 100 )
Send ( "deviantart.com {ENTER}" ) ; removed the ^6
WinWaitActive ( "deviantART" ); Changed titles case

Sleep ( 2500 )
PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

If @error Then
    Restart1()
Else
    MsgBox ( 0, "Good News!", "Color was found!" )
EndIf

; ============== FUNCTIONS ==============

Func ExitProg()
    Exit
EndFunc

Func Restart1()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        Restart2()
    Else
        MsgBox ( 0, "Good News!", "Color was found 2nd Time!" )
    EndIf
EndFunc

Func Restart2()
    Sleep ( 2500 )
    PixelSearch ( 0, 0, 600, 600, $iColor, 0 )

    If @error Then
        MsgBox ( 0, "Error!", "Error" )
    Else
        MsgBox ( 0, "Good News!", "Color was found 3th Time!" )
    EndIf
EndFunc

Bob

The F6 Is to select the address bar :)
Link to comment
Share on other sites

The F6 Is to select the address bar :)

F6 does not always work, at least not on mt firefox. If the focus is in the window it does, but if a blank browser window comes up, the focus is already there and it removes it. I guess you have a Homepage set and I don't.

Bob

--------------------bobchernow, Bob ChernowWhat a long strange trip it's beenUDFs: [post="635594"]Multiple Monitor Screen Resolution Change[/post]

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