Jump to content
Sign in to follow this  
automation

ControlSend

Recommended Posts

automation

Hi I am new to Autoit

I am using Autoit in conjuction with Watir for desktop application.

Here is my code, I have to construct the URL depending on different parameters and then pass it to ControlSend so I can automate this process

require "watir"

require "dbi"

require "net/http"

require 'watir/testcase'

require "win32/process" # opening and closind applications

require "win32ole"

autoit=WIN32OLE.new("AutoItX3.Control")

# module to launch play url using winamp, needs to pass play url

module LaunchPlayUrl

def LaunchPlayUrl.launchPlayUrl(playUrl)

# Launch Winamp application

puts playUrl

autoit=WIN32OLE.new("AutoItX3.Control")

autoit.Run('C:\Program Files\Winamp\winamp.exe') # another post indicated double quotes do not work as in actual autoit script use single instead works.

#Activate Winamp window

autoit.WinWaitActive("Winamp 5.56")

autoit.Send("^l")

autoit.WinWaitActive("Open URL")

autoit.ControlSend("Open URL", "", "Edit1", $playUrl)

autoit.sleep(5000)

autoit.ControlClick("Open URL", "&Open", "Button1")

end

end

When I use this code value of $playUrl is not getting in the ControlSend and it is typing blank in the Edit field.

Please Help!

Share this post


Link to post
Share on other sites
zfisherdrums

Hey automation,

I don't work that much in Ruby, so I apologize if this doesn't help you out. By looking at the code, '$playUrl' refers to a global variable, while the defined function receives a parameter entitled 'playUrl'. If the global variable isn't defined, that may explain why it is entering a blank value.

Zach...

Share this post


Link to post
Share on other sites
automation

Hey automation,

I don't work that much in Ruby, so I apologize if this doesn't help you out. By looking at the code, '$playUrl' refers to a global variable, while the defined function receives a parameter entitled 'playUrl'. If the global variable isn't defined, that may explain why it is entering a blank value.

Zach...

Thanks for replying, I am initializing this variable while calling this module method, and I tried printing using puts too which is a valid string that I am passing when calling the method. but when I try to use that value in ControlSend it is null, I even tried passing local variable but did not work.

Share this post


Link to post
Share on other sites
zfisherdrums

Try removing the '$' in front of '$playUrl'.

Current:

autoit.ControlSend("Open URL", "", "Edit1", $playUrl)

Updated:

autoit.ControlSend("Open URL", "", "Edit1", playUrl)

Share this post


Link to post
Share on other sites
automation

Try removing the '$' in front of '$playUrl'.

Current:

autoit.ControlSend("Open URL", "", "Edit1", $playUrl)

Updated:

autoit.ControlSend("Open URL", "", "Edit1", playUrl)

I tried that too but did not work. I tried assigning global variable value to local variable and using local variable instead of global, but did not work.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.