CaptainBeardsEyesBeard Posted March 14, 2018 Share Posted March 14, 2018 Hi Guys, I've got this Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") WinWaitActive("Elite Enterprise Matter") sleep(500) ControlClick("Elite Enterprise Matter", "", "[CLASS:Button; INSTANCE:1;]") ;click ok Navigation_Click_OK_To_Saved_Matter() ; click ok WinClose ( "Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Wanker", $RecordSaveSuccess) if $RecordSaveSuccess = StringInStr($RecordSaveSuccess, "Successfull saved") then MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Matter Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves " & $RecordSaveSuccess) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Passed") ElseIf Then MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves Test Failed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Failed") EndIf When I call the MSBOX to output the variable $RecordSaveSuccess the msgbox is empty as well as the FileWrite of $RecordSaveSuccess So I have 2 questions : how do I properly grab the content of this box And why was the test "passing" rather than failing when it saw my $RecordSaveSuccess was empty? Link to comment Share on other sites More sharing options...
rcmaehl Posted March 14, 2018 Share Posted March 14, 2018 (edited) 10 minutes ago, CaptainBeardsEyesBeard said: Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") WinWaitActive("Elite Enterprise Matter") sleep(500) ControlClick("Elite Enterprise Matter", "", "[CLASS:Button; INSTANCE:1;]") ;click ok Navigation_Click_OK_To_Saved_Matter() ; click ok WinClose ( "Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Wanker", $RecordSaveSuccess) if $RecordSaveSuccess = StringInStr($RecordSaveSuccess, "Successfull saved") then MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Matter Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves " & $RecordSaveSuccess) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Passed") ElseIf Then MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves Test Failed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Failed") EndIf A couple things from your code: Successfull saved, did you mean Successfully saved You're comparing a String $RecordSaveSuccess to a Integer value StringInStr. Which will cause issues and probably always return true ElseIf Then, did you mean Else? Example with these issues fixed: Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") WinWaitActive("Elite Enterprise Matter") sleep(500) ControlClick("Elite Enterprise Matter", "", "[CLASS:Button; INSTANCE:1;]") ;click ok Navigation_Click_OK_To_Saved_Matter() ; click ok WinClose ( "Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Wanker", $RecordSaveSuccess) if StringInStr($RecordSaveSuccess, "Successfully saved") then MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Matter Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves " & $RecordSaveSuccess) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Passed") Else MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves Test Failed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Failed") EndIf Edited March 14, 2018 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 Damn that's annoying. So I guess the next question is how do I pull the data out the control boxcorrectly? And how do I check if "Successfully saved" is in the string I pull out? Thanks Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 (edited) well you for sure need to move Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") to after WinClose ( "Eliter Enterprise Matter") ; close window Edited March 14, 2018 by Bilgus Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 Why would I do that? The close window function closes the window with the content I'm looking for (that a matter has been saved). Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 also WinWait Active Passes back an Hwnd Local $hWnd_EEM = WinWaitActive("Elite Enterprise Matter") sleep(500) ControlClick($hWnd_EEM, "", "[CLASS:Button; INSTANCE:1;]") ;click ok Navigation_Click_OK_To_Saved_Matter($hWnd_EEM) ; click ok WinClose ( $hWnd_EEM) ; close window .... Func Navigation_Click_OK_To_Saved_Matter($hWnd) ... ..Click..($hwnd).. EndFunc Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 if you can check the status of a successful save before saving it then what good does it do? Link to comment Share on other sites More sharing options...
rcmaehl Posted March 14, 2018 Share Posted March 14, 2018 5 minutes ago, Bilgus said: well you for sure need to move Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") to after WinClose ( "Eliter Enterprise Matter") ; close window Not sure where you're getting this from... My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 (edited) Hmm not sure what you guys mean. (Pretty new to autoIT!) I'll start from the beginning So after saving a matter this window pops up (on the left) I would like to take out the string from this box which says "Successfully saved records for ABA110-1297168" Run an if statement to check if the variable contains "Successfully saved" If it does PASS TEST then output to a text file If it doens't contain "Successfully saved" fail test and output to a text file. Edited March 14, 2018 by CaptainBeardsEyesBeard Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 Extra context helps I was reading your missing function in the script 'Navigation_Click_OK_To_Saved_Matter() ; click ok' as when you actually save the record Local $hWnd = WinWait("Elite Enterprise Matter", "Successfully saved", 10) Sleep(500) If $hWnd Then ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:1;]") ;click ok ;;;? ? ? Navigation_Click_OK_To_Saved_Matter() ; click ok WinClose("Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Matter Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves " & "Test Passed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Passed") Else ;Maybe?? WinClose("Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves Test Failed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Failed") EndIf Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 (edited) So if I'm understanding this correctly - It will wait until a window with a title of "Elite Enterprise Matter" and text inside of "Successfully saved" comes up before executing further? Because ideally I want to grab the full text in the box (so I can output this to a test case with the matter number) as well as to check the matter number is incrementing Edited March 14, 2018 by CaptainBeardsEyesBeard Link to comment Share on other sites More sharing options...
Zedna Posted March 14, 2018 Share Posted March 14, 2018 In your first post change this (incorrect): Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") to this (correct): Local $hWnd = WinWait("Elite Enterprise Matter", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static2") Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 Win wait Should match with that partial text if you need the record number still the after a successful match do this $sRecord = StringReplace(WinGetText($hWnd, ""), "Successfully saved records for "); or use regexp to parse out a valid record number ;If $Record <> "" Then If you can't get the text to match then switch to [Title:Elite Enterprise Matter; CLASS:Static] Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2018 Share Posted March 14, 2018 And It will wait 10 seconds for that title before failing Local $hWnd = WinWait("Elite Enterprise Matter", "Successfully saved", 10) ; waits 10 seconds Local $hWnd = WinWait("Elite Enterprise Matter", "Successfully saved") ; Waits FOREVER Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 13 minutes ago, Zedna said: In your first post change this (incorrect): Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") to this (correct): Local $hWnd = WinWait("Elite Enterprise Matter", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static2") Thanks man this sorted it. Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted March 14, 2018 Author Share Posted March 14, 2018 (edited) 48 minutes ago, rcmaehl said: A couple things from your code: Successfull saved, did you mean Successfully saved You're comparing a String $RecordSaveSuccess to a Integer value StringInStr. Which will cause issues and probably always return true ElseIf Then, did you mean Else? Example with these issues fixed: Local $hWnd = WinWait("[CLASS:Static]", "", 10) Local $RecordSaveSuccess = ControlGetText($hWnd, "", "Static") WinWaitActive("Elite Enterprise Matter") sleep(500) ControlClick("Elite Enterprise Matter", "", "[CLASS:Button; INSTANCE:1;]") ;click ok Navigation_Click_OK_To_Saved_Matter() ; click ok WinClose ( "Eliter Enterprise Matter") ; close window MsgBox($MB_SYSTEMMODAL, "Wanker", $RecordSaveSuccess) if StringInStr($RecordSaveSuccess, "Successfully saved") then MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & " Result", "Test Passed, Matter Saved", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves " & $RecordSaveSuccess) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Passed") Else MsgBox($MB_SYSTEMMODAL, "Test" + $TestCount & " Result", "Test Failed", 4) FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure matter saves Test Failed") FileWrite($hFilehandle, @CRLF & "Test" & $TestCount & " Create a new matter using " & $MatterNumber & "as a model matter Ensure Matter has incremented Test Failed") EndIf This if statement now works for me All working now! Many thanks! Edited March 14, 2018 by CaptainBeardsEyesBeard Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted March 14, 2018 Share Posted March 14, 2018 what did you learn today? My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
rcmaehl Posted March 14, 2018 Share Posted March 14, 2018 26 minutes ago, Earthshine said: what did you learn today? Mitochondria is the powerhouse of the cell.... no wait that was middle school. Earthshine 1 My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF 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