Drac89 Posted January 28, 2019 Posted January 28, 2019 How do i exit from a while loop when a window exists ? I tried do until Winexist("Confirm Exit") but still it isnt exiting. I tried below as well but it isnt working. Can anyone please help ? expandcollapse popup#include <Constants.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> If $CmdLine[0] <> 2 Then MsgBox($MB_OK, "Usage", "saphana <username> <password>") Else saphana($CmdLine[1], $CmdLine[2]) EndIf Global $sData Func saphana($username, $password) Global $spid = Run("C:\Program Files\sap\hdbstudio\hdbstudio.exe") MsgBox($MB_OK, "Usage", "script"&$spid,2,"") Global $flag = 1 Global $PID = WinWait("hdbstudio - SAP HANA Administration Console - SAP HANA Studio") Local $lpid = ProcessExists($spid) MsgBox($MB_OK, "Usage", "script2"&$lpid,2,"") While $flag = 1 MsgBox($MB_OK, "Usage", "script3"&$PID,2,"") $hwnd = WinWait("Database User Logon -") ; Ensure we are in the Username fieldm ; Send the instance ControlFocus($hWnd, "", "Edit1") ControlClick($hWnd, "", "Edit1", "left", 2,"","") Send("^c") ;Copy selected text. $sData = ClipGet() ;Retrieves text from clipboard. $PID = WinWait("hdbstudio - SAP HANA Administration Console - SAP HANA Studio") Local $cmp= StringCompare($sData,$username) If $cmp = 0 Then Send("{TAB}") ; Ensure we are in the Password field ; Send the Password Send($password, 1) ; Submit the credentials Send("{ENTER}") ElseIf WinExists ("Confirm Exit") Then ExitLoop Else MsgBox($MB_OK, "Usage", "Not allowed to access",2,"") WinWaitClose($hwnd) EndIf WEnd WinWaitClose($hwnd) EndFunc ;==>saphana()
BigDaddyO Posted January 28, 2019 Posted January 28, 2019 put the "WinExists ("Confirm Exit") Then" into it's own If statement. If the $cmp = 0 then it will never check the ElseIf
Drac89 Posted January 28, 2019 Author Posted January 28, 2019 Oh okay, so I do the if cmp =0 and the else not allowed to access- a separate if else. Then a separate' if 'for win exists? So the' if win exists' should return a true value if the window exists right? It can be used in a if statement. Okay ll test n see
Drac89 Posted January 29, 2019 Author Posted January 29, 2019 17 hours ago, BigDaddyO said: put the "WinExists ("Confirm Exit") Then" into it's own If statement. If the $cmp = 0 then it will never check the ElseIf no it isnt working still...it isnt detecting the window Handle .This is the window and i used the autoitinfo tool and it is detecting but still in the loop , its nt working. I want to exit the loop when the application stops running.I tried processexist in the do until condition and nothing, it is still not exiting.Can anyone please help. It is SAP hana studio client.
Nine Posted January 29, 2019 Posted January 29, 2019 I think it is your while logic that is not working. You should check credentials and if un/pw are right then start looping until the window (Confirm Exit) appears...So remove your while where it is currently. And replace it by something like : do Sleep (500) until WinExists ("Confirm Exit") BTW Win* () (in your case it is winwait) does not return a pid, but window handle...Make sure that WinExists detects that exit window ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Drac89 Posted February 3, 2019 Author Posted February 3, 2019 On 1/29/2019 at 6:09 PM, Nine said: I think it is your while logic that is not working. You should check credentials and if un/pw are right then start looping until the window (Confirm Exit) appears...So remove your while where it is currently. And replace it by something like : do Sleep (500) until WinExists ("Confirm Exit") BTW Win* () (in your case it is winwait) does not return a pid, but window handle...Make sure that WinExists detects that exit window ! The thing is I need to send the username and password only if it detects another window and that window if prompted, I check the username that's in it and if the username matches with what's being passed, then I pass credential and it logs in. And if username is nt same, then it gives out a message. And whenever the user choose the sap Hana tenant, it should do the above and once confirm exit window is seen, it has to get out of the loop. And I am nt able to detect that window at all, I dno how to make it detect.
Nine Posted February 3, 2019 Posted February 3, 2019 Can you show us what Au3Info tool says about this window ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Drac89 Posted February 4, 2019 Author Posted February 4, 2019 (edited) 11 hours ago, Nine said: Can you show us what Au3Info tool says about this window ? Hi Nine Below is the screenshot :- I tried with the text inside the confirm Exit window as well but it doesnt seem to work. Should i put the title in a variable and then use that variable in Winexists ? Thank you for taking the time. Edited February 4, 2019 by Drac89
Nine Posted February 4, 2019 Posted February 4, 2019 4 hours ago, Drac89 said: Should i put the title in a variable and then use that variable in Winexists ? Doesn't matter, it will not change the result. Now we know that the title of the Window is right. So it must be your code logic that is causing not to work. To debug it, I suggest you put multiple msgbox everywhere and follow the path of your logic. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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