Jump to content

Recommended Posts

Posted

I am having trouble getting this set to a function. The function would be assigned to a button on a single gui.

here is the complete code i have been playing with:

#region ---Au3Recorder generated code Start ---


Global $Paused
        HotKeySet("{PAUSE}", "TogglePause")
        HotKeySet("{ESC}", "Terminate")
        HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d


        



#include <ComboConstants.au3>
        #include <EditConstants.au3>
        #include <GUIConstantsEx.au3>


Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",1)

_WinWaitActivate("microsoft excel - ","")
        
        
        
    
       

        



        Local $test1, $test1a, $test2, $test2a, $test3, $test3a, $test4, $test4a, $test5, $test5a, $test6, $test6a, $test7, $test7a, $test8, $test8a, $test9, $test9a 
        Local $test10, $test10a, $answer1, $answer2, $answer3, $answer4, $answer5, $answer6, $answer7, $answer8, $answer9, $answer10, $thc1, $thc2, $answer11
        Local $co1, $co1a, $com1, $co2, $co2a, $com2, $co3, $co3a, $com3, $co4, $co4a, $com4, $co5, $co5a, $com5, $ct, $tc, $ct1



        ; code to get test positions from ini

        $test1 = IniRead("C:\test\test.ini", "test Positions", "test #1", $answer1)
        $test1a = StringSplit($test1, ",")
        $test2 = IniRead("C:\test\test.ini", "test Positions", "test #2", $answer2)
        $test2a = StringSplit($test2, ",")
        $test3 = IniRead("C:\test\test.ini", "test Positions", "test #3", $answer3)
        $test3a = StringSplit($test3, ",")
        $test4 = IniRead("C:\test\test.ini", "test Positions", "test #4", $answer4)
        $test4a = StringSplit($test4, ",")
        $test5 = IniRead("C:\test\test.ini", "test Positions", "test #5", $answer5)
        $test5a = StringSplit($test5, ",")
        $test6 = IniRead("C:\test\test.ini", "test Positions", "test #6", $answer6)
        $test6a = StringSplit($test6, ",")
        $test7 = IniRead("C:\test\test.ini", "test Positions", "test #7", $answer7)
        $test7a = StringSplit($test7, ",")
        $test8 = IniRead("C:\test\test.ini", "test Positions", "test #8", $answer8)
        $test8a = StringSplit($test8, ",")
        $test9 = IniRead("C:\test\test.ini", "test Positions", "test #9", $answer9)
        $test9a = StringSplit($test9, ",")
        $test10 = IniRead("C:\test\test.ini", "test Positions", "test #10", $answer10)
        $test10a = StringSplit($test10, ",")


           ;   misc cord codes =\

        $thc1 = IniRead("C:\test\test.ini", "misc Position", "TH ", $answer11)
        $thc2 = StringSplit($thc1, ",")


           ; time to misc 
           
        $co1 = IniRead("C:\test\test.ini", "misc ", "misc ", $com1)
        $co1a = StringSplit($co1, ",")
        $co2 = IniRead("C:\test\test.ini", "misc ", "button3 ", $com2)
        $co2a = StringSplit($co2, ",")
        $co3 = IniRead("C:\test\test.ini", "misc ", "button2 ", $com3)
        $co3a = StringSplit($co3, ",")
        $co4 = IniRead("C:\test\test.ini", "misc ", "button1 ", $com4)
        $co4a = StringSplit($co4, ",")
        $co5 = IniRead("C:\test\test.ini", "Misc ", "OK ", $com5)
        $co5a = StringSplit($co5, ",")

        ; click on button to get to resize form

        $ct = iniread("C:\test\test.ini", "Misc ", "form ", $tc)
        $ct1 = StringSplit($ct, ",")



        ; example : Mouseclick("left", $test1a[1], $test1a[2], 1)










        ; test #1
                            
                            if $test1 <=0 Then
                                MsgBox(4096, "ESB ( Error 119 )", "You need to Adjust your settings")
                            
                                
                            EndIf   
            
                            
            
            
            while 1

                if $test1 > 0 Then



                                

                                Mouseclick("left", $test1a[1], $test1a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))

                                
                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf


        ; test #2
            

                if $test2 > 0 Then



                    

                                Mouseclick("left", $test2a[1], $test2a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps

                EndIf


        ; test #3
            

                if $test3 > 0 Then




                                Mouseclick("left", $test3a[1], $test3a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf


        ; test #4

            

                if $test4 > 0 Then



                    

                                Mouseclick("left", $test4a[1], $test4a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf


        ; test #5
            

                if $test5 > 0 Then



                    

                                Mouseclick("left", $test5a[1], $test5a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps

                EndIf



        ; test #6

                if $test6 > 0 Then



                    

                                Mouseclick("left", $test6a[1], $test6a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf




        ; test #7
            

                if $test7 > 0 Then



                    
                                Mouseclick("left", $test7a[1], $test7a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps

                EndIf



        ; test #8
            

                if $test8 > 0 Then



                    

                                Mouseclick("left", $test8a[1], $test8a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps

                EndIf



        ; test #9
            

                if $test9 > 0 Then



                    
                                Mouseclick("left", $test9a[1], $test9a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf



        ; test #10
            

                if $test10 > 0 Then



                    

                                Mouseclick("left", $test10a[1], $test10a[2], 5) ; clicks on the test box 1a
                                Sleep(Random(2550,2750))


                                Mouseclick("left", $ct1[1], $ct1[2], 5) ; clicks on box 20b
                                Sleep(Random(2550,2750))
                                
                                Mouseclick("left", $thc2[1], $thc2[2], 5)   ; clicks on the box 10d
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co1a[1], $co1a[2], 5)   ; clicks on the new page tab
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co2a[1], $co2a[2], 5)   ; clicks on the arrow
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co3a[1], $co3a[2], 5)   ; clicks on menu file
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co4a[1], $co4a[2], 5)   ; clicks on the save button
                                Sleep(Random(2550,2750))

                                Mouseclick("left", $co5a[1], $co5a[2], 5)   ; clicks ok
                                Sleep(Random(2550,2750))     ; sleeps


                EndIf




                    Sleep(random(930000,960000))   ; sleeps between 15.5 and 16.5 minutes. then repeats.
            WEnd            
            
        

                #region --- Internal functions Au3Recorder Start ---
            Func _WinWaitActivate($title,$text,$timeout=0)
                WinWait($title,$text,$timeout)
                If Not WinActive($title,$text) Then WinActivate($title,$text)
                WinWaitActive($title,$text,$timeout)
            EndFunc
            #endregion --- Internal functions Au3Recorder End ---
            #endregion --- Au3Recorder generated code End ---

                
                While 1
                        Sleep(100)
                    WEnd
                    ;;;;;;;;

                    Func TogglePause()
                        $Paused = NOT $Paused
                        While $Paused
                            sleep(100)
                            ToolTip('Script is "Paused"',0,0)
                        WEnd
                        ToolTip("")
                    EndFunc

                    Func Terminate()
                        main()
                        exit 0
                        
                    EndFunc

                    Func ShowMessage()
                        MsgBox(4096,"","This is a message.")
                    EndFunc

and when i try to add

#region ---Au3Recorder generated code Start ---


Global $Paused
        HotKeySet("{PAUSE}", "TogglePause")
        HotKeySet("{ESC}", "Terminate")
        HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d


        



#include <ComboConstants.au3>
        #include <EditConstants.au3>
        #include <GUIConstantsEx.au3>


Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",1)

_WinWaitActivate("microsoft excel - ","")
begin()

          func begin()

and end it with:

endfunc

    While 1
                        Sleep(100)
                    WEnd
                    ;;;;;;;;

                    Func TogglePause()
                        $Paused = NOT $Paused
                        While $Paused
                            sleep(100)
                            ToolTip('Script is "Paused"',0,0)
                        WEnd
                        ToolTip("")
                    EndFunc

                    Func Terminate()
                        main()
                        exit 0
                        
                    EndFunc

                    Func ShowMessage()
                        MsgBox(4096,"","This is a message.")
                    EndFunc

I get this message : C:\Users\Main\Desktop\test185.au3(500,4) : ERROR: syntax error

Func

^

when i run the syntaxCheck, when i click go it gives me the same thing.

Any ideas? (me)>> :( << (autoit) lol

Posted (edited)

endfunc

    While 1
                        Sleep(100)
                    WEnd
                    ;;;;;;;;

                    Func TogglePause()
                        $Paused = NOT $Paused
                        While $Paused
                            sleep(100)
                            ToolTip('Script is "Paused"',0,0)
                        WEnd
                        ToolTip("")
                    EndFunc

                    Func Terminate()
                        main()
                        exit 0
                    EndFunc ; There was a space here, it might have cause the other functions to glitch, not sure. Try again?

                    Func ShowMessage()
                        MsgBox(4096,"","This is a message.")
                    EndFunc

Also, I tested your complete code.

It says main() is an undefined function.

I didn't see an error with Func

Edited by Penisaurus
Posted

yes the main is assigned to go back to the gui when the esc is pressed.

i have tried it again. and i keep getting the same error. but it is pointing to this line

Func _WinWaitActivate($title,$text,$timeout=0)
hmm. when i leave the func out of it, it works just fine. but i cant activate it without a func =\
Posted

yes the main is assigned to go back to the gui when the esc is pressed.

i have tried it again. and i keep getting the same error. but it is pointing to this line

Func _WinWaitActivate($title,$text,$timeout=0)
hmm. when i leave the func out of it, it works just fine. but i cant activate it without a func =\

I think it's because WinWaitActivate is an already existing function, so you can't add a function to a function, I don't think.

Perhaps something like this.

Func WinWaitActivate()
    _WinWaitActivate
EndFunc

_WinWaitActivate($title,$text,$timeout=0)

I might be wrong though.

Posted (edited)

:( ah that didnt work. i will play with it some more and keep checking for clues.

but if anyone else wants to take a crack at it.. I dont want to be the only one banging my head lol

Edited by cueclub
Posted

ah i got it. grrr note to who ever sees this, when you are looking at something for 2 hrs straight and cant seem to see the problem. STEP AWAY for a min.

i had forgotten a wend and had had to double check where the space was =\

thanks Penisaurus :(

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
×
×
  • Create New...