Jump to content

Difficulty with Edit keyboard entry


Recommended Posts

I have an application that needs to have a password entered into two fields, but try as I might, I cannot get the text fields to fill in anything. I'm hoping that I've overlooked something obvious.

"Enter Password" is the dialog box.

1058060490_EnterPasssword.png.83fe79e6551215c8072d897acb163e35.png

Here's a screenshot of the Window Inspector after selecting the top Password edit box:

1449164882_WindowInspector.png.e8950fe58f4ad6db747d1da6467b845c.png

The lower Password edit box is ID#3. The username field comes pre-filled.

I've tried a number of different options, including Send, ControlSetText, ControlSend. None of these will fill in the edit dialog. If I sleep in the script, and type on the keyboard, it will enter text into the text box.

I've also tried to activate the Edit3 field using ControlFocus, but that doesn't work either. I know I have the right window because I am doing a WinActivate and it does pull the window to the foreground.

Here's some of my code. It's a little bit of a mess as I've tried a couple different methods.

Opt ("WinTitleMatchMode", 4)
$appName = "Enter Your Password"
$appHandle = WinGetHandle($appName, "")
WinActivate($appHandle)

Sleep(1000)
ControlSetText($appHandle, "", "[CLASS:Edit; INSTANCE:3]", "This is some text")
Sleep(1000)
Send("{TAB}")
ControlFocus($appHandle, "", "Edit3")
Sleep(1000)
Send("Some text",1)
Send("{ENTER}")

If I open a notepad window and click over to it immediately after the WinActivate, I do see the Send commands type into that window. I've written other macros before with success, but I'm not an AutoIt expert at all.

Anyone have any ideas about how I might try to move forward on this problem? Is it possible that this app is somehow detecting AutoIt and refusing to accept input from it? Is that a thing?

Link to comment
Share on other sites

Maybe you're not getting the window handle somehow.

how does it work like this?

Opt ("WinTitleMatchMode", 3)
$appName = "Enter Your Password"
WinWait($appName)
WinActivate($appName)
ConsoleWrite($appName&@CRLF)
ControlSetText($appName, "", "[CLASS:Edit; INSTANCE:3]", "This is some text")
Sleep(1000)
Send("{TAB}")
ControlFocus($appName, "", "Edit3")
Sleep(1000)
Send("Some text", 1)
Send("{ENTER}")

It's always helpful to place some consolewrites with the variables to see if they are what is expected.

I did that with a test application and got all zeroes as the handle, as soon as i ditched the handle, it all works.

PS any special reason to use the flag 4 for the OPT?

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I'll give this a try and get back to you. We were having issues with activating the window without the MatchMode, and the first example I found used 4, which worked, so I didn't experiment further. I'll try 3 as you suggested and see how I get along. Thanks for your response!

Link to comment
Share on other sites

I tried the script as suggested above, and while it does still activate the window with MatchMode 3, and I do get the expected console output of "Enter Your Password", I still do not get any action from the window itself, either text or the changing of focus on Edit controls.

Link to comment
Share on other sites

Since you haven't said what the application is that you're talking about, which makes helping you that much harder, any suggestions are just guesses as to what the issue may be.  One guess for the odd behavior is that you are dealing with an application that requires elevated privileges.  An un-elevated process sometimes has issues communicating with processes that require elevation, especially the sending of keystrokes.  One thing you can try is to add the #RequireAdmin directive to your script to see if it works.

Edited by TheXman
Link to comment
Share on other sites

Thanks, I'll try that out and see what happens, but I am fairly sure the application is not running with elevated privileges at the time that this window is active.

The application is Profile Wizard, from ForensIT, but unfortunately you need a very specific set of circumstances to get the app to give you this dialog box, and the version of the app that has this functionality is commercial software, so I can't easily point someone at a binary to test against.

Link to comment
Share on other sites

To be clear, I am saying that your script may need elevated privileges to send keystrokes to that prompt.  Hence, the reason for trying the #RequireAdmin directive in your script.

Link to comment
Share on other sites

Yeah, I'm going to test that and report back. It'll throw a little wrench into things if I need to elevate autoit, but I think we'll be able to work that out, and at least we'll have a viable direction to keep going in. Thanks again.

Link to comment
Share on other sites

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...