devilburnz Posted January 6, 2020 Share Posted January 6, 2020 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 More sharing options...
Subz Posted January 6, 2020 Share Posted January 6, 2020 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 devilburnz 1 Link to comment Share on other sites More sharing options...
devilburnz Posted January 6, 2020 Author Share Posted January 6, 2020 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 More sharing options...
Subz Posted January 6, 2020 Share Posted January 6, 2020 (edited) 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 January 7, 2020 by Subz devilburnz 1 Link to comment Share on other sites More sharing options...
devilburnz Posted January 7, 2020 Author Share Posted January 7, 2020 (edited) 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 January 7, 2020 by devilburnz Link to comment Share on other sites More sharing options...
Subz Posted January 7, 2020 Share Posted January 7, 2020 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now