Hey all,
my first entry in the community, yeah!
I wrote the following script, which aims to do an automated login.
I encountered several challenges.
In general, I have the issue, that the input done by AHK is unreliable.
If I use the script, sometimes the input is just fine, sometimes characters are missing / where not written in the specific row.
Even "SetKeyDelay" didn't solve it.
Another challenge is the change of the domain.
I could either write the username first and than say @ e.g. "user@domain", or choose backslash, e.g. "domain\user".
Inserting either one of the symbols "@" or "\" was not easy.
The current version of the script shows the most reliable form.
Furthermore, how can I "loop" the script, so that it always does the "WinWaitActive"?
----------------------
#Persistent
User= myUserID
Pass= myPassw
WinWaitActive, Windows-Sicherheit ; Windows-Sicherheit is the window name to logon to
SetKeyDelay 100
ControlSendRaw, Edit1, ads\%User% ; the user needs to change the domain to ADS, hence the backslash is necessary, row name "Edit1"
sleep 1000
Send {tab} ; change in the passwort row called "Edit2"
ControlSendRaw, Edit2,%Pass% ;
sleep 10000
Send, {Enter}
return
---------------------
unreliable string input by AHK
-
- Posts: 1
- Joined: 21 Mar 2018, 03:58
Re: unreliable string input by AHK
Instead of using ControlSendRaw, you can use regular ControlSend and escape the special characters by putting a ` (the key above Tab) behind them. So `% will send a % symbol, for example. You could also save the string to a variable and then ControlSend the variable, which might improve reliability.
Another option would be using ControlSetText instead of ControlSend.
Another option would be using ControlSetText instead of ControlSend.
- divanebaba
- Posts: 804
- Joined: 20 Dec 2016, 03:53
- Location: Diaspora
Re: unreliable string input by AHK
Hello PeteThePope.
MaxAstro means, you can "mask" or "escape" some special characters.
Maybe it is necessary, to writeBtw: Welcome to the AHK-forum.
MaxAstro means, you can "mask" or "escape" some special characters.
Maybe it is necessary, to write
Code: Select all
ControlSend, Edit1, ads`\%User%
Re: unreliable string input by AHK
Escaping \ with ` has no effect and is therefore never necessary.
ControlSendRaw is appropriate, as the variables may contain characters which ControlSend would interpret as modifiers, such as ^ or #. Escaping these with ` would be totally ineffective. Without Raw (or {Text}), they would have to be "escaped" by surrounding them with curly braces, even if inside a variable: {^}.
For an Edit control, ControlSetText should be the most reliable option.
For anything else, I would suggest using {Text} mode instead of Raw.
ControlSendRaw is appropriate, as the variables may contain characters which ControlSend would interpret as modifiers, such as ^ or #. Escaping these with ` would be totally ineffective. Without Raw (or {Text}), they would have to be "escaped" by surrounding them with curly braces, even if inside a variable: {^}.
For an Edit control, ControlSetText should be the most reliable option.
For anything else, I would suggest using {Text} mode instead of Raw.