Jump to content

for loop and count the array


Recommended Posts

Hi guys,

i need some help in programming, the sample code is working as expected. however, there is an error and the scripts ends,

what i trying to do is make windows to check first on which windowtitle i am at, then next it will proceed to do the steps eg moue click on a specific page.

the error i am getting is $checkout = $array[$cartcheckout]

$checkout = ^ ERROR.

any advise please? thanks!

local $cartcheckout = 0
local $array[2]

$array[0] = "this is an apple"
$array[1] "this is an orange"

For $cartcheckout = 0 to 1

while 1

$checkout = $array[$cartcheckout]

if WinActivate($checkout,"") then
mouseclick("Left",22,22,1)
elseif WinWaitNotActive($checkout,"") then
sleep(20)
$cartcheckout += 1

EndIf
WEnd

 

Link to comment
Share on other sites

6 minutes ago, Subz said:

You don't need the While loop 

For $cartcheckout = 0 to 1
    $checkout = $array[$cartcheckout]
    if WinActivate($checkout,"") then
        mouseclick("Left",22,22,1)
    elseif WinWaitNotActive($checkout,"") then
        sleep(20)
    EndIf
next

 

thanks subz, it works, i guess i still got more to learn :) 

Link to comment
Share on other sites

np: If you want to wait for the window then you can use while loop example (untested):
Used ControlClick as this is a better option then MouseClick.

Local $iCheckOut, $aCheckOut[2] = ["this is an apple", "this is an orange"]

While 1
    If WinExists($aCheckOut[0], "") Then
        WinActivate($aCheckOut[0], "")
        ControlClick($aCheckOut[0], "", "", "Left",1, 22,22)
        $iCheckOut = 0
        ExitLoop
    ElseIf WinExists($aCheckOut[1], "") Then
        WinActivate($aCheckOut[1], "")
        ControlClick($aCheckOut[1], "", "", "Left",1, 22,22)
        $iCheckOut = 1
        ExitLoop
    EndIf
    Sleep(100)
WEnd

MsgBox(4096, "Checkout", "Checkout Window = " & $aCheckOut[$iCheckOut])

 

Edited by Subz
Link to comment
Share on other sites

23 hours ago, Subz said:

np: If you want to wait for the window then you can use while loop example (untested):
Used ControlClick as this is a better option then MouseClick.

Local $iCheckOut, $aCheckOut[2] = ["this is an apple", "this is an orange"]

While 1
    If WinExists($aCheckOut[0], "") Then
        WinActivate($aCheckOut[0], "")
        ControlClick($aCheckOut[0], "", "", "Left",22,22,1)
        $iCheckOut = 0
        ExitLoop
    ElseIf WinExists($aCheckOut[1], "") Then
        WinActivate($aCheckOut[1], "")
        ControlClick($aCheckOut[1], "", "", "Left",22,22,1)
        $iCheckOut = 1
        ExitLoop
    EndIf
    Sleep(100)
WEnd

MsgBox(4096, "Checkout", "Checkout Window = " & $aCheckOut[$iCheckOut])

 

does controlclick works for windows application class such as NETUIHWND? it seems no matter what i tried for the coords, it does not click on what i want.  possible if it can done via a controlclick on window title instead of coords?

Edited by devilburnz
Link to comment
Share on other sites

Just realized the code I posted with ControlClick was incorrect, I used your MouseClick, but forgot that the last three parameters were in the wrong order, it should have been ", 1, 22, 22)" I can confirm coords work with NetUIHWND, I did a simple test on Outlook ribbon which has NETUIHWND class.

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