Atrax27 Posted July 7, 2020 Posted July 7, 2020 I have a webpage that I would like to Focus the Input on a particular field, which is not automatically set as the initial input. Website: https://fiscaloffice.summitoh.net/PropertyTaxValues/PayTaxCC.htm I want to just simply use the Send(“154xxx”) into the “Parcel” field, then Send(“{ENTER}”) without cycling through tab presses each time before getting to the correct inputbox, where number of tab press numbers might change depending on a few things (using either IE, chrome, etc). On most websites I try this with, the “Login ID” field is the first one that the cursor jumps to so all I do is just start a Send command, but here I can’t do that since it’s not the initial cursor location. I’ve read a few things on the forums about “_WinAPI_SetFocus” but that appears to work on AutoIT generated form fields only (see below code), I don’t know how to translate it for website use, thanks for any help! #include <GUIConstantsEx.au3> #Include <WinAPI.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 400, 20) GUICtrlCreateButton("Test", 10, 100, 80, 30) GUICtrlSetState(-1, $GUI_FOCUS) GUISetState() Sleep(5000) _WinAPI_SetFocus(ControlGetHandle("Test", "", $hInput)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
Danp2 Posted July 7, 2020 Posted July 7, 2020 If you're using IE, then use the appropriate functions from the IE UDF. You can locate the element with _IEGetObjByName and then set it's value with _IEFormElementSetValue. P.S. I found your post confusing, so my apologies if my reply isn't on target Latest Webdriver UDF Release Webdriver Wiki FAQs
Atrax27 Posted July 10, 2020 Author Posted July 10, 2020 OK, reading up on the UDFs. If you click the link above to the online tax payment site and let it load you'll see what I mean. 1) click link and wait for page to load 2) press TAB seven times 3) start typing the parcel ID 4) press enter How do I skip step 2? How do I make the cursor jump right to the input field?
Danp2 Posted July 10, 2020 Posted July 10, 2020 I already pointed you to the functions you need above -- On 7/7/2020 at 3:31 PM, Danp2 said: You can locate the element with _IEGetObjByName and then set it's value with _IEFormElementSetValue. Read up on these in the help file. Try them out in your own script and then let us know how it goes. 😃 Atrax27 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
Atrax27 Posted July 10, 2020 Author Posted July 10, 2020 9 minutes ago, Danp2 said: I already pointed you to the functions you need above -- Read up on these in the help file. Try them out in your own script and then let us know how it goes. 😃 Perfect, works flawlessly thank you. ------------- #include <IE.au3> Local $oIE = _IECreate("https://fiscaloffice.summitoh.net/PropertyTaxValues/PayTaxCC.htm") Local $oForm = _IEFormGetObjByName($oIE, "web") Local $oInputFile = _IEFormElementGetObjByName($oForm, "parcel") _IEAction($oInputFile, "focus") _IEAction($oInputFile, "selectall") Send("Thanks Danp2")
Danp2 Posted July 10, 2020 Posted July 10, 2020 2 minutes ago, Atrax27 said: Send("Thanks Danp2") That's not the proper way to do this (Send is ). What you want is _IEFormElementSetValue($oInputFile, "Thanks again!") Latest Webdriver UDF Release Webdriver Wiki FAQs
Atrax27 Posted July 10, 2020 Author Posted July 10, 2020 35 minutes ago, Danp2 said: That's not the proper way to do this (Send is ). What you want is _IEFormElementSetValue($oInputFile, "Thanks again!") Well that streamlined things a bit... I may start using that instead of send from now on. Why don't you like send usually? ...... #include <IE.au3> Local $oIE = _IECreate("https://fiscaloffice.summitoh.net/PropertyTaxValues/PayTaxCC.htm") Local $oForm = _IEFormGetObjByName($oIE, "web") Local $oInputFile = _IEFormElementGetObjByName($oForm, "parcel") _IEFormElementSetValue($oInputFile, "Danp2 is a rockstar")
Danp2 Posted July 10, 2020 Posted July 10, 2020 Send is the least reliable way to update / send text to an application or web browser. Therefore, it should only be used as a last resort. P.S. See the following for the correct method of posting code to the forum Latest Webdriver UDF Release Webdriver Wiki FAQs
Atrax27 Posted July 10, 2020 Author Posted July 10, 2020 1 hour ago, Danp2 said: Send is the least reliable way to update / send text to an application or web browser. Therefore, it should only be used as a last resort. P.S. See the following for the correct method of posting code to the forum Nice! Looks like the mobile site is missing those choices unfortunately.
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