[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Issue with ControlSend function using AutoIT in Ruby

Skye Weir-mathewes

5/25/2007 5:52:00 PM

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?

--
Posted via http://www.ruby-....

5 Answers

Chris Hulan

5/25/2007 7:50:00 PM

0

On May 25, 1:51 pm, Skye Weir-Mathews <carpeur...@gmail.com> wrote:
....SNIP...
> 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

Skye Weir-mathewes

5/29/2007 8:44:00 PM

0

ChrisH wrote:
> 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.

--
Posted via http://www.ruby-....

Jano Svitok

5/29/2007 10:03:00 PM

0

On 5/29/07, Skye Weir-Mathews <carpeursus@gmail.com> wrote:
> ChrisH wrote:
> > 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.

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

Skye Weir-mathewes

6/8/2007 11:14:00 PM

0


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

--
Posted via http://www.ruby-....

Skye Weir-mathewes

8/6/2007 6:52:00 PM

0

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}")
--
Posted via http://www.ruby-....