automation Posted November 12, 2009 Share Posted November 12, 2009 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! Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 12, 2009 Share Posted November 12, 2009 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... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
automation Posted November 12, 2009 Author Share Posted November 12, 2009 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. Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 12, 2009 Share Posted November 12, 2009 Try removing the '$' in front of '$playUrl'. Current: autoit.ControlSend("Open URL", "", "Edit1", $playUrl) Updated: autoit.ControlSend("Open URL", "", "Edit1", playUrl) Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
automation Posted November 12, 2009 Author Share Posted November 12, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now