CaptainBeardsEyesBeard Posted December 5, 2018 Share Posted December 5, 2018 So I'm trying to find out why it's not inputting into this rate box however I never get the error msg I've put in for error handling Func InputRate($Rate) Local $hWnd1 = WinWait("[CLASS:ThunderRT6FormDC]", "", 10)ControlSend($hWnd1, "", "ThunderRT6TextBox13", $Rate) If @error = 1 Then MsgBox(($MB_ICONINFORMATION, "", "Cannot enter $Rate number") EndIf FileWrite($hFilehandle, @CRLF & $Rate) Sleep(4000) EndFunc How come I don't get the msgbox? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 5, 2018 Developers Share Posted December 5, 2018 Where does it state in the helpfile that the @eeror is set? Quote Return Value Success: a handle to the requested window. Failure: 0 if timeout occurred. Just test for the returned value in $hWnd1. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted December 5, 2018 Author Share Posted December 5, 2018 OK, so to do that I would do the below? I tried it and it doesn't work either. Func InputRate($Rate) Local $hWnd1 = WinWait("[CLASS:ThunderRT6FormDC]", "", 10) ControlSend($hWnd1, "", "ThunderRT6TextBox13", $Rate)If $hWnd1 = 1 Then MsgBox(($MB_ICONINFORMATION, "", "Cannot enter $Rate number") EndIf FileWrite($hFilehandle, @CRLF & $Rate) Sleep(4000) EndFunc Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted December 5, 2018 Share Posted December 5, 2018 (edited) 18 minutes ago, CaptainBeardsEyesBeard said: If $hWnd1 = 1 Then That's not the way you check if you have a valid handle. Take a look at IsHWnd() function. And, watch out of your indentation... Edited December 5, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted December 5, 2018 Share Posted December 5, 2018 If you want to test for an error then test for the value that is returned in case of an error. This value is 0 (according to Jos' post. So try: Func InputRate($Rate) Local $hWnd1 = WinWait("[CLASS:ThunderRT6FormDC]", "", 10) If $hWnd1 = 0 Then MsgBox(($MB_ICONINFORMATION, "", "Cannot enter $Rate number") Else ControlSend($hWnd1, "", "ThunderRT6TextBox13", $Rate) FileWrite($hFilehandle, @CRLF & $Rate) EndIf EndFunc My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted December 5, 2018 Author Share Posted December 5, 2018 Bizarre I tried that and still don't get any msg box coming up to say it's failed Link to comment Share on other sites More sharing options...
Danp2 Posted December 5, 2018 Share Posted December 5, 2018 Post your code so that we can the the revisions you have made. Also, isn't it possible that there's another window with this same class? Try using WinList to get a list of matching windows and then display the resulting array. Latest Webdriver UDF Release Webdriver Wiki FAQs 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