Jump to content

ControlSend sends czech characters instead of number


Recommended Posts

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

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 by Seminko
cleanup
Link to comment
Share on other sites

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 by Seminko
Link to comment
Share on other sites

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

Yup, done that. When I click it, it opens the sources tab with a wall of code longer than an encyclopedia.

image.thumb.png.2e25a7ad9addb5577281f07e945d68ed.png

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...