Jump to content

declaring global varriable inside?


 Share

Recommended Posts

it doesnt seem to work any ideas? im trying to automate our inventory sales data i hope u can help me

Global $pants = 1

Func Main()
While 1


$data1 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
If isArray($data1) then
send ("{ALTDOWN}")
sleep(60)
Send("{0 down}")
sleep(60)
Send("{0 up}")
sleep(60)
send ("{ALTUP}")
SLEEP(50)
MouseClick("primary", $data1[0] +5, $data1[1] +5, 1, 0)
SLEEP(900)
Global $pants = 0       ;--- HELP ME ON THIS, IT DONT SEEM TO WORK


else

$data2 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
If isArray($data2) then
MouseClick("primary", $data2[0] +5, $data2[1] +5, 1, 0)
SLEEP(500)


Else
   if $pants = 0    Then              ;--- HELP ME ON THIS, IT DONT SEEM TO WORK 
   send ("{ALTDOWN}")
   sleep(60)
   Send("{9 down}")
   sleep(60)
   Send("{9 up}")
   sleep(60)
   send ("{ALTUP}")
    SLEEP(50)
    Global $pants= 1                    ;--- HELP ME ON THIS, IT DONT SEEM TO WORK
else
     Global $pants = 1                     ;--- HELP ME ON THIS, IT DONT SEEM TO WORK
      sleep(100)



EndIf
endif
endif
WEnd
EndFunc


 

Link to comment
Share on other sites

You only need to declare the variable once. This is how I would do it inside the function. Your
 script might need more work afterwards...

Main()

Func Main()
    Local $data1, $data2, $pants = 1

    While 1
        $data1 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
        If IsArray($data1) Then
            Send("{ALTDOWN}")
            Sleep(60)
            Send("{0 down}")
            Sleep(60)
            Send("{0 up}")
            Sleep(60)
            Send("{ALTUP}")
            Sleep(50)
            MouseClick("primary", $data1[0] + 5, $data1[1] + 5, 1, 0)
            Sleep(900)
            $pants = 0
        Else
            $data2 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
            If IsArray($data2) Then
                MouseClick("primary", $data2[0] + 5, $data2[1] + 5, 1, 0)
                Sleep(500)
            Else
                If $pants = 0 Then
                    Send("{ALTDOWN}")
                    Sleep(60)
                    Send("{9 down}")
                    Sleep(60)
                    Send("{9 up}")
                    Sleep(60)
                    Send("{ALTUP}")
                    Sleep(50)
                    $pants = 1
                Else
                    $pants = 1
                    Sleep(100)
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc

 

Edited by ripdad
sp

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

@nimbus42

i did some fix on your script(i did paste $pants = 0) after else:

Global $pants = 1, $data1, $data2
WinWaitActive("title here") ;;
Main()
Func Main()
    While 1


        $data1 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
        If isArray($data1) then
            send("{ALTDOWN}")
            sleep(60)
            Send("{0 down}")
            sleep(60)
            Send("{0 up}")
            sleep(60)
            send("{ALTUP}")
            SLEEP(50)
            MouseClick("primary", $data1[0] + 5, $data1[1] + 5, 1, 0)
            SLEEP(900)
            $pants = 0


        else
            $pants = 0
            $data2 = PixelSearch(356, 247, 726, 594, 0x6B29A5)
            If isArray($data2) then
                MouseClick("primary", $data2[0] + 5, $data2[1] + 5, 1, 0)
                SLEEP(500)


            Else
                if $pants = 0 Then
                    send("{ALTDOWN}")
                    sleep(60)
                    Send("{9 down}")
                    sleep(60)
                    Send("{9 up}")
                    sleep(60)
                    send("{ALTUP}")
                    SLEEP(50)
                    $pants = 1
                else
                    $pants = 1
                    sleep(100)



                EndIf
            endif
        endif
    WEnd
EndFunc   ;==>Main

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

  • Developers

@ad777, Is your Tidy program still broken? What about you run Tidy before posting code so it is readable? ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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