2

I've run into an odd problem with AutoIT's ControlSend function on Windows 7, so I'm hoping someone can help.

I've written FUSE filesystem, which is shared with Windows via Samba. I'm trying to automate tests of the filesystem on Windows using AutoIT to write and modify files on the filesystem with a variety of different applications.

When I first kicked off the tests I was using the "Send" method to send keystrokes, but I found that other applications would occasionally steal focus and my tests would grind to a hault. I hoped that using ControlSend would allow my tests to proceed even if focus was stolen. The problem I'm running into is that sometimes modifier keys (like Shift and Control) aren't sent as they should be.

For example, if I use

ControlSend("Open", "", "Edit1", "Z:\test.txt")

to set the path in an open dialog, I will occasionally see the text come across as "z;|test.txt", apparently having inverted the shift key for a few characters.

In another case, if I send

ControlSend($hWnd, "", "Edit1",  "^o")

To send "Ctrl+o" to a Notepad Window, I will occasionally find that instead of bringing up the Open dialog, AutoIT simply types the letter "o" into the Notepad text field.

I need to be able to set up these scripts and let them run for continued periods unmonitored, so having it occasionally type characters that are explicitly not what it was supposed to send make it an unworkable solution.

Is there something I can do to make it more consistent about sending the right characters with the right modifiers?

1

1 Answer 1

2

AutoIt in my experience messes the send keys up sometimes but only if they are send rapidly after another.

The function ControlSend has a flag, right after the string you want it to send which makes AutoIt to send the keys raw or not.

ControlSend ( "title", "text", controlID, "string" [, flag = 0] )

Flag changes how "keys" is processed:

0 = (default) Text contains special characters like + to indicate SHIFT and {LEFT} to indicate left arrow.

1 = keys are sent raw

For the Ctrl.+o problem try to make it like this:

ControlSend ( "title", "", 0, "^{o}")

hope this helped :)

Sign up to request clarification or add additional context in comments.

1 Comment

Is that to say that setting flag=1 would prevent the case errors I'm seeing intermittently? The random case changes don't seem to surround special characters, they just seem to come up when cases change in my text. I'll try and see if ^{0} works better than ^0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.