Issue with ControlSend function using AutoIT in Ruby

S

Skye Weir-Mathews

I'm having an issue running scripts that use AutoIT against my windows
box, half the time the ControlSend function sends a string to the GUI
that should be all upcase, in a hodge-podge of different case letters.

Example:

I'm trying to send a string to a window with the following variables,
ext.
(this isn't the actual code, just the pertinent bits)

@datestring = date.year.to_s + "_" + date.month.to_s + "_" +
date.day.to_s
@hostname = `hostname`
@hostname = @hostname.upcase.to_s.chomp

autoit = WIN32OLE.new("AutoItX3.Control")
autoit.ControlSend("Enter SQL Database Information", "", 302,
"LMNIGHTLY#{@hostname}#{@datestring}")


Most of the time this will send a string like
"LMNIGHTLYHOSTNAME2007_5_25" but occasionally it sends a string like
"lMNIgHTlyHOsTNAME2007_5_2".

At other places in the script it has the send the same string to a
system call, and this always comes out correctly, so it seems like it's
just a problem with AutoIT.

Also the issue seems specific to some aspect of my windows configuration
because the script runs fine on some servers and not on others.

Has anyone had experience with this issue before?
 
C

ChrisH

Most of the time this will send a string like
"LMNIGHTLYHOSTNAME2007_5_25" but occasionally it sends a string like
"lMNIgHTlyHOsTNAME2007_5_2".

At other places in the script it has the send the same string to a
system call, and this always comes out correctly, so it seems like it's
just a problem with AutoIT.
....SNIP...

The AutoItX docs indicate the the Send command is sensitive to the
state of Caps Lock
and also can be affected is a user happens to be holding down SHIFT
when the command
is executed. Would explain the intermittent/seemingly system dependent
behavior...

Cheers
Chris Hulan
 
S

Skye Weir-Mathews

ChrisH said:
The AutoItX docs indicate the the Send command is sensitive to the
state of Caps Lock
and also can be affected is a user happens to be holding down SHIFT
when the command
is executed. Would explain the intermittent/seemingly system dependent
behavior...

Cheers
Chris Hulan

This worked well at first, but then my issue came back which is
confusing to me, because I've run a number of tests making absolutely
sure that Caps Lock is turned off and I wasn't touching the keyboard at
all. Interestingly enough when AutoIT send a bad string, it always
downcases the same letters (when "LMNIGHTLYHOSTNAME2007_5_25" is bad, it
always looks like "lMNIgHTlyHOsTNAME2007_5_2") which makes me think that
it's not related to input from the keyboard, which is likely to be
different every time.
 
J

Jano Svitok

This worked well at first, but then my issue came back which is
confusing to me, because I've run a number of tests making absolutely
sure that Caps Lock is turned off and I wasn't touching the keyboard at
all. Interestingly enough when AutoIT send a bad string, it always
downcases the same letters (when "LMNIGHTLYHOSTNAME2007_5_25" is bad, it
always looks like "lMNIgHTlyHOsTNAME2007_5_2") which makes me think that
it's not related to input from the keyboard, which is likely to be
different every time.

This seems to be an issue with autoit itself. At first I intended to
ask you to try with standalone autoit, but then I googled a bit, and
found [1]. So look at autoit site if there's a solution. I'm too
sleepy to do anything more now.

Jano

[1] http://www.autoitscript.com/forum/index.php?showtopic=15499
 
S

Skye Weir-Mathews

Okay, I think I figured it out, my script was automating an installer
and sending messages to STDOUT letting me know how it was progressing
through the installation

for example:

puts "Enter Microsoft SQL Database Authentication Information"

autoit.WinWait("Enter Microsoft SQL Database Authentication
Information", "", 5)

autoit.ControlSend("Enter Microsoft SQL Database Authentication
Information", "", 301, "XXX")

autoit.ControlSend("Enter Microsoft SQL Database Authentication
Information", "", 302, "XXX")

autoit.ControlSend("Enter Microsoft SQL Database Authentication
Information", "", 1, "{ENTER}")

so, I noticed that when the script was running in the background it
installed fine, and when it was running in the foreground I got the
funky chars. Since then I commented out the lines like puts "Enter
Microsoft SQL Database Authentication Information" and it seems to be
running fine.

Thanks ya'll
 
S

Skye Weir-Mathews

Just in case anyone else finds this post looking for resolution with
this issue, redirecting STDOUT didn't actually fix anything. What really
worked was changing the parts where I was sending text to the screen
from using the ControlSend function to using ControlSetText. Now my
script looks like this and seems to be working great.

puts "Enter SQL Database Information"
autoit.WinWait("Enter SQL Database Information", "", 5)
autoit.ControlSetText("Enter SQL Database Information", "", 301,
"#{@dbserver}")
autoit.ControlSetText("Enter SQL Database Information", "", 302,
"LMNIGHTLY#{@hostname}#{@datestring}")
autoit.ControlSend("Enter SQL Database Information", "", 1,
"{ENTER}")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top