2
votes

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
A little late, but I experienced the same problem and finally found a solution. I've written it up here: stackoverflow.com/questions/42588904/…slackwing

1 Answers

2
votes

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 :)