Seminko Posted August 5, 2019 Share Posted August 5, 2019 I've been using my script for quite some time now without an issue but lately ControlSend started sending czech characters instead of numbers. For example, when I send "6", received is "ž". In czech, SHIFT + ž sends 6. However, I cannot grasp why 6 would get translated to ž. The funny thing is, only the first letter is "translated", so if I send '6642679', received is 'ž642679'. Relevant code: $login = "6642679" Local $oIE = _IECreate($URL, False, $visible) _IELoadWait($oIE) $hWnd = _IEPropertyGet($oIE, "hwnd") $UserNameInput = _IEGetObjById($oIE, "userID") If @error Then MsgBox(16, "Error", "Can't find Username.") Return False Else _IEAction($UserNameInput, "click") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $login) If @error Then MsgBox(16, "Error", "Can't set value $UserNameInput") Return False EndIf EndIf I tried the raw parameter, also string to hex --> hex to string. Nothing seems to work. Could it have something to do with the site? Link to comment Share on other sites More sharing options...
Danp2 Posted August 5, 2019 Share Posted August 5, 2019 Since you're using IE, you would normally use _IEFormElementSetValue instead of ControlSend. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 5, 2019 Author Share Posted August 5, 2019 I'm using _IEFormElementSetValue for the password but for some reason it doesn't work for the user ID, hence the controlsend. Link to comment Share on other sites More sharing options...
Danp2 Posted August 5, 2019 Share Posted August 5, 2019 Are you able to provide the URL so that we can take a look at the site? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 6, 2019 Author Share Posted August 6, 2019 Here it is: https://online.mbank.cz/cs/Login Link to comment Share on other sites More sharing options...
Danp2 Posted August 6, 2019 Share Posted August 6, 2019 Looks pretty standard to me. Can you post your script showing where you tried using _IEFormElementSetValue for both input fields and then submitting the form? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 6, 2019 Author Share Posted August 6, 2019 (edited) Oh right, now I remember. It's not about _IEFormElementSetValue not working. It works, it correctly fills the username (without the 'ž' issue), however the 'Potvrdit' (submit) button does not get activated. It probably detects that the input was set instead of typed. Anyways, here's the code. Try running it and check the submit button. #Include <IE.au3> $login = "6642679" $pass = "rand0mstr1ng" $URL = "https://online.mbank.cz/cs/Login" Local $oIE = _IECreate($URL) _IELoadWait($oIE) $PassInput = _IEGetObjById($oIE, "pass") If @error Then MsgBox(16, "Error", "Can't find Password") Else _IEFormElementSetValue($PassInput, $pass) If @error Then MsgBox(16, "Error", "Can't set value $PassInput") EndIf EndIf Sleep(750) $UserNameInput = _IEGetObjById($oIE, "userID") If @error Then MsgBox(16, "Error", "Can't find Username.") Else _IEAction($UserNameInput, "focus") _IEFormElementSetValue($UserNameInput, $login) If @error Then MsgBox(16, "Error", "Can't set value $UserNameInput") EndIf EndIf Edited August 6, 2019 by Seminko cleanup Link to comment Share on other sites More sharing options...
Danp2 Posted August 6, 2019 Share Posted August 6, 2019 The site uses jQuery and it only enables the button under certain conditions. The condition check is called on a keyup event, so the following will trigger the event for you -- $oIE.document.parentwindow.execScript('jQuery("#pass").trigger("keyup");') Seminko 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 6, 2019 Author Share Posted August 6, 2019 (edited) That's awesome. Thanks! How does one find out? Edited August 6, 2019 by Seminko Link to comment Share on other sites More sharing options...
Danp2 Posted August 6, 2019 Share Posted August 6, 2019 Use the browser's developer tools to examine the website, see what events are attached to the elements, and then figure out which ones you need to trigger. Personally, I prefer to do this type of analysis in Chrome or Firefox. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 6, 2019 Author Share Posted August 6, 2019 (edited) 1 hour ago, Danp2 said: Use the browser's developer tools to examine the website, see what events are attached to the elements, and then figure out which ones you need to trigger. Personally, I prefer to do this type of analysis in Chrome or Firefox. Yea I know dev tools, elements, XPath etc but I've never dealt with events. So how do I find what events are attached to what elements? I suspect I select an element, go to event listeners and in this case I can see there's keyup. Where did you get the jQuery name, though. Edited August 6, 2019 by Seminko Link to comment Share on other sites More sharing options...
Danp2 Posted August 6, 2019 Share Posted August 6, 2019 3 hours ago, Seminko said: Where did you get the jQuery name, though Not sure about IE, but in Chrome or Firefox they show the event and it's source. In this case it shows jQuery, and from past experience I know that "jQuery" will reference the main jQuery object. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 8, 2019 Author Share Posted August 8, 2019 I'm using chrome on my pc too. I use IE only for AutoIt use, because I haven't gotten into WebDriver yet. Still, can't find the jQuery info in Chrome... Could you post a screen from where you get the info, please? That would help a lot. Link to comment Share on other sites More sharing options...
Danp2 Posted August 8, 2019 Share Posted August 8, 2019 Open DevTools and then type "jQuery" into the console. Once you hit enter, it should show you the associated object Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 8, 2019 Author Share Posted August 8, 2019 Yup, done that. When I click it, it opens the sources tab with a wall of code longer than an encyclopedia. Even few days ago when you posted the reply I tried searching for '#pass' or just 'pass' in the javascript but haven't found anything that looked right to me. How did you find what you were looking for? Link to comment Share on other sites More sharing options...
Danp2 Posted August 8, 2019 Share Posted August 8, 2019 Yeah... don't do that. 😀 That's the javascript behind the jQuery library. You need to research jQuery and get a better understanding of the options for selecting elements (xpath, css, etc). This will come in handy when using the WebDriver UDF as well. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 9, 2019 Author Share Posted August 9, 2019 That's the thing. I know about those What I don't know is JS (much). $("#test").hide() - hides the element with id="test". Alright, now I get it... So your example: 'jQuery("#pass").trigger("keyup");' triggers keyup on element with id='pass', which is the password input. Cool. The interesting part is that the submit button becomes active only after you filled in your login and at least 8chars of a password. Do I understand correctly that (probably) some other script checks for that and after the conditions are met it triggers the keyup event, which in turn enables the button? Now, how did you know it was keyup that triggered that? Based on experience or did you find out from the page itself? If so, where? Link to comment Share on other sites More sharing options...
Danp2 Posted August 9, 2019 Share Posted August 9, 2019 Basically, it's trial & error. I examined the element for attached events. Reviewed these and manually triggered them until I achieved the desired effect. Then implemented that in Autoit. P.S. I believe in this case that the "change" event would also have worked. Seminko and Bilgus 1 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Seminko Posted August 9, 2019 Author Share Posted August 9, 2019 Alright. Thanks for the explanation! Very much appreciated. Link to comment Share on other sites More sharing options...
Zedna Posted August 9, 2019 Share Posted August 9, 2019 As about ControlSend and native characters problem, look here at my very old but still "intact" topic with mentioned workarounds: Resources UDF ResourcesEx UDF AutoIt Forum Search 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