Jump to content

Looping Query


Go to solution Solved by ioa747,

Recommended Posts

Posted (edited)

Good day,

My truly sincerest apologies for this one...but can someone please assist me in getting started with the example...

; -----------------------------------------------
#include <AutoItConstants.au3>
; -----------------------------------------------
Global $iTimeOut = 100
Global $hSAWSTUDIO_MAIN = "CLASS:SAWSTUDIO_MAIN"
; -----------------------------------------------
Example()
; -----------------------------------------------
Func Example()
    Item1()
    OtherItems()
EndFunc   ;==>Example
; -----------------------------------------------
Func Item1()
    WinActivate($hSAWSTUDIO_MAIN)
    ; -----------------------------------------------
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 360, 180, 1, 0) ; FOR TESTING ONLY!!
    ; -------------------------
    Send("{F2}")
    ; Select item > Custom Cmds > Add
    ; 1st Item
    Sleep($iTimeOut)
    Send("{UP}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
EndFunc   ;==>Item1
; -----------------------------------------------
Func OtherItems()
    ; Select item > Custom Cmds > Add
    ; 2nd Item
    Sleep($iTimeOut)
    Send("{HOME}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
    ; -------------------------
    ; 3rd Item
    Sleep($iTimeOut)
    Send("{DOWN}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
    ; -------------------------
    ; 4th Item
    Sleep($iTimeOut)
    Send("{DOWN}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
    ; -------------------------
    ; 5th Item
    Sleep($iTimeOut)
    Send("{DOWN}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
EndFunc   ;==>OtherItems
; -----------------------------------------------

As can be observed in the "OtherItems()" function, there are multiple items that require being added to a list.
• Though the above example shown 5 items, there are in total 32 items!
• Thus, I would require 31 iterations for this listing...from Item 2 to Item 32.

Any assistance in this matter would be greatly appreciated!

 

Edited by mr-es335
  • mr-es335 changed the title to Looping Query
  • Solution
Posted (edited)
Func OtherItems()
        ; 2nd Item
        ConsoleWrite("2) Item -----" & @CRLF)
        Sleep($iTimeOut)
        Send("{HOME}")
        Sleep($iTimeOut)
        MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
        Sleep($iTimeOut)
        Send("{DOWN}+{ENTER}")
    
    For $i = 3 to 32
        ConsoleWrite($i & ") Item -----" & @CRLF)
        Sleep($iTimeOut)
        Send("{DOWN}")
        Sleep($iTimeOut)
        MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
        Sleep($iTimeOut)
        Send("{DOWN}+{ENTER}")
    Next

EndFunc   ;==>OtherItems

:)

Edited by ioa747
correction

I know that I know nothing

Posted

@ioa747, maybe you (or copilot) overlooked something, it's only in the 2nd item he has {HOME}, in the other 3 he has {DOWN}.

Or is it me who is overlooking something. 😛

 

Some guy's script + some other guy's script = my script!

Posted (edited)

Hello,

1) As noted, there is a list of 32 items.
2) As the list terminates on the last entry, I need to go to the top of the list - via Send("{HOME}")
3) At this point, the Func Item1() selects the first item as this function employs the initial Home command.
4) Items 2-32 are identical in operation.

In launching the provided example script, I am getting duplicate output of the top 3 items?

Also. the example script includes two functions - when I do believe that I only require one - one of Item 1, and one for items 2 to 32.

PS: Just for completeness, the end result of this script is to create a 2nd list of the data.

Edited by mr-es335
Posted

Hello,

Okay....updating the example provided by ioa747...here is what I have...and it DOES APPEAR to work as expected...

Spoiler
; -----------------------------------------------
#include <AutoItConstants.au3>
; -----------------------------------------------
Global $iTimeOut = 100
; ---------------------
Global $hSAWSTUDIO_MAIN = "CLASS:SAWSTUDIO_MAIN"
Global $hSAWSTUDIO_MULTITRACK = "[CLASS:SAWSTUDIO_MULTITRACK]"
; -----------------------------------------------
; Add the 27 Control Track Cmds to Custom Cmds
; -----------------------------------------------
PartB()
; -----------------------------------------------
Func PartB()
    SelectI01()
    SelectF2()
    FirstItem()
    OtherItems()
    SelFirstItem()
EndFunc   ;==>PartB
; -----------------------------------------------
Func SelectI01()
    WinActivate($hSAWSTUDIO_MULTITRACK)
    ; -----------------------------------------------
    Sleep($iTimeOut)
    Send("{DOWN}")
EndFunc   ;==>SelectI01
; -----------------------------------------------
SelectF2()
Func SelectF2()
    WinActivate($hSAWSTUDIO_MAIN)
    ; -----------------------------------------------
    Sleep($iTimeOut)
    Send("{F2}")
EndFunc   ;==>SelectF2
; -----------------------------------------------
Func FirstItem()
    ConsoleWrite("Add Item #1" & @CRLF)
    Sleep($iTimeOut)
    Send("{HOME}")
    Sleep($iTimeOut)
    MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
    Sleep($iTimeOut)
    Send("{DOWN}+{ENTER}")
EndFunc   ;==>FirstItem
; -----------------------------------------------
Func OtherItems()
    For $i = 2 To 3
        ConsoleWrite("Add Item #" & $i & @CRLF)
        Sleep($iTimeOut)
        Send("{DOWN}")
        Sleep($iTimeOut)
        MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
        Sleep($iTimeOut)
        Send("{DOWN}+{ENTER}")
    Next
EndFunc   ;==>OtherItems
; -----------------------------------------------
Func SelFirstItem()
    Sleep($iTimeOut)
    Send("{HOME}")
EndFunc   ;==>SelFirstItem
; -----------------------------------------------

 

Thanks again to the both of your...especially to ioa747!!!

Posted
#include <AutoItConstants.au3>
; -----------------------------------------------
Global $iTimeOut = 100
; ---------------------
Global $hSAWSTUDIO_MAIN = "CLASS:SAWSTUDIO_MAIN"
Global $hSAWSTUDIO_MULTITRACK = "[CLASS:SAWSTUDIO_MULTITRACK]"
; -----------------------------------------------
; Add the 27 Control Track Cmds to Custom Cmds
; -----------------------------------------------
PartB()
; -----------------------------------------------
Func PartB()
    SelectI01()
    SelectF2()
    AddItems(27) ; 👈 Add 27 Items and SelFirstItem
EndFunc   ;==>PartB
; -----------------------------------------------
Func SelectI01()
    WinActivate($hSAWSTUDIO_MULTITRACK)
    ; -----------------------------------------------
    Sleep($iTimeOut)
    Send("{DOWN}")
EndFunc   ;==>SelectI01
; -----------------------------------------------
Func SelectF2()
    WinActivate($hSAWSTUDIO_MAIN)
    ; -----------------------------------------------
    Sleep($iTimeOut)
    Send("{F2}")
EndFunc   ;==>SelectF2
; -----------------------------------------------
Func AddItems($iItems = 1)
    Local $sKey ; dummy
    For $i = 1 To $iItems
        ConsoleWrite("Add Item #" & $i & @CRLF)
        Sleep($iTimeOut)
        $sKey = ($i = 1 ? Send("{HOME}") : Send("{DOWN}"))
        Sleep($iTimeOut)
        MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0)
        Sleep($iTimeOut)
        Send("{DOWN}+{ENTER}")
    Next

    ; SelFirstItem
    Sleep($iTimeOut)
    Send("{HOME}")
EndFunc   ;==>AddItems
; -----------------------------------------------

 

I know that I know nothing

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