Jump to content
Sign in to follow this  
howdytest

For...In and Arrays

Recommended Posts

howdytest

I've been trying to write a script to gather 4 forex charts and print them on one page.

Local $pairs[4] = ["EURUSD","USDJPY","GBPUSD","GBPJPY"]
Local $pairsx[4] = [552, 754, 569, 695]             ;x coords for corresponding $pair
Local $pairsy[4] = [270, 352, 509, 650]             ;y coords for corresponding $pair
Local $pairsSAx[4] = [624, 823, 623, 766]
Local $pairsSAy[4] = [589, 669, 423, 562]

Local $excelx[4] = [66, 504, 63, 509]               ;x coords for pasting into excel
Local $excely[4] = [172, 172, 480, 480]             ;y coords for pasting into excel

For $element IN $pairs
    FOR $element IN $pairsx
        For $element IN $pairsy
            For $element IN $excelx
                For $element IN $excely
                    For $element IN $pairsSAx
                        For $element IN $pairsSAy

WinActivate ($pairs)

MouseClick ("Right" ,$pairsx ,$pairsy , 1 , 10)     ;Right Click on chart
MouseClick ("Left" , $pairsSAx, $pairsSAy , 1 , 10) ;Save As Pic
MouseClick ("Left" , 448, 448 , 1 , 10)             ;Sets Active Chart as Save type
MouseClick ("Left" , 597, 486 , 1 , 10)             ;Hits ok
MouseClick ("Left" , 597, 486 , 1 , 10)             ;Selects the Filename box
Send ($pairs)                                       ;Sends pair name to save file under
MouseClick ("Left" , 785, 465 , 1 , 10)             ;Save
MouseClick ("Left" , 599, 416 , 1 , 10)             ;Replace "yes"
MouseClick ("Right", 411, 427, 1 , 10)              ;Right Clicks on picture
MouseClick ("Left" , 457, 664 , 1 , 10)             ;Copy
WinClose ("Documents and Settings")
WinActivate ("Excel")
MouseClick ("Right" , $excelx, $excely , 1 , 5)     ;right clicks in excel
MouseClick ("Left" , 56, 58 , 1 , 10)               ;pastes in excel

Next
Next
Next
Next
Next
Next
Next

So i have 7 arrays, 6 of which for coords. I was looking for a way to run through the mouse clicks with all of the array's using the same index number...$pairs[0] is related to $pairsx[0] and $pairsy[0]. I thought For...In was the loop to use for this purpose, but when i'm running the script, aside from funky mouse coord problems, it seems to run through all of the coords.

Outside of my funky mouse coord problems, does this block of code look like it should do what i want?

Thanks

Share this post


Link to post
Share on other sites
Valuater

Maybe...

Local $pairs[4] = ["EURUSD", "USDJPY", "GBPUSD", "GBPJPY"]
Local $pairsx[4] = [552, 754, 569, 695] ;x coords for corresponding $pair
Local $pairsy[4] = [270, 352, 509, 650] ;y coords for corresponding $pair
Local $pairsSAx[4] = [624, 823, 623, 766]
Local $pairsSAy[4] = [589, 669, 423, 562]

Local $excelx[4] = [66, 504, 63, 509] ;x coords for pasting into excel
Local $excely[4] = [172, 172, 480, 480] ;y coords for pasting into excel

For $i = 0 To 3
    

    WinActivate($pairs[$i])

    MouseClick("Right", $pairsx[$i], $pairsy[$i], 1, 10) ;Right Click on chart
    MouseClick("Left", $pairsSAx[$i], $pairsSAy[$i], 1, 10) ;Save As Pic
    MouseClick("Left", 448, 448, 1, 10) ;Sets Active Chart as Save type
    MouseClick("Left", 597, 486, 1, 10) ;Hits ok
    MouseClick("Left", 597, 486, 1, 10) ;Selects the Filename box
    Send($pairs[$i]) ;Sends pair name to save file under
    MouseClick("Left", 785, 465, 1, 10) ;Save
    MouseClick("Left", 599, 416, 1, 10) ;Replace "yes"
    MouseClick("Right", 411, 427, 1, 10) ;Right Clicks on picture
    MouseClick("Left", 457, 664, 1, 10) ;Copy
    WinClose("Documents and Settings")
    WinActivate("Excel")
    MouseClick("Right", $excelx[$i], $excely[$i], 1, 5) ;right clicks in excel
    MouseClick("Left", 56, 58, 1, 10) ;pastes in excel

Next

8)


NEWHeader1.png

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  

×