Sign in to follow this  
Followers 0
joppertom

WinActivate under Ruby

7 posts in this topic

I am tasked with validating the AutoIt functionality running under Ruby 1.8.6. I seem to be having trouble with the WinActivate() method. After the method is called notepad stays minimized and even if I restore the window it doesn't Send(). If I comment out WinActivate() I can restore the window and the text is sent.

Thanks,

Tom

require 'win32ole'

au3 = WIN32OLE.new "AutoItX3.Control"
au3.opt "WinTextMatchMode", 3

au3.Run "notepad.exe"
au3.WinWait("Untitled - Notepad", "", 5)
au3.Send("R-1{TAB}OUTPUT{ENTER}")
au3.WinMinimizeAll( )

au3.WinActivate("Untitled - Notepad", "")
au3.WinWaitActive("Untitled - Notepad", "", 20)
au3.Send("R-2{TAB}OUTPUT{ENTER}")

Share this post


Link to post
Share on other sites



Tried it... same results...

require 'win32ole'

au3 = WIN32OLE.new "AutoItX3.Control"
au3.opt "WinTextMatchMode", 3

au3.Run "notepad.exe"
au3.WinWait("Untitled - Notepad", "", 5)
au3.Send("R-1{TAB}OUTPUT{ENTER}")
au3.WinMinimizeAll( )

#au3.WinActivate("Untitled - Notepad", "")
au3.WinSetState( "Untitled - Notepad", "", @SW_RESTORE )
au3.WinWaitActive("Untitled - Notepad", "", 20)
au3.Send("R-2{TAB}OUTPUT{ENTER}")

Share this post


Link to post
Share on other sites

First restore then activate then wait for it to be activated.

#...
au3.WinSetState( "Untitled - Notepad", "", @SW_RESTORE )
au3.WinActivate("Untitled - Notepad", "")
au3.WinWaitActive("Untitled - Notepad", "", 20)
#...


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I think that it has something to do with notepad. Perhaps I will use another program to validate this function.

a1.WinActivate("Calculator", "")
a1.WinWaitActive("Calculator", "", 20)
a1.WinActivate("Untitled - Notepad", "")
a1.WinWaitActive("Untitled - Notepad", "", 20)
a1.Send("R-2{TAB}OUTPUT{ENTER}")
a1.WinActivate("Calculator", "")
a1.WinWaitActive("Calculator", "", 20)
a1.WinActivate("Untitled - Notepad", "")
a1.WinWaitActive("Untitled - Notepad", "", 20)
a1.Send("R-3{TAB}OUTPUT{ENTER}")
a1.WinActivate("Calculator", "")
a1.WinWaitActive("Calculator", "", 20)
a1.WinActivate("Untitled - Notepad", "")
a1.WinWaitActive("Untitled - Notepad", "", 20)
a1.Send("R-4{TAB}OUTPUT{ENTER}")

Share this post


Link to post
Share on other sites

It was Notepad that was the problem. The code behaves very well with WordPad.

Thank you,

Tom

:graduated:

Share this post


Link to post
Share on other sites

Hmmm, I didn't try that! Perhaps on Monday. :graduated: Ready to sneak out of here for the weekend!

First restore then activate then wait for it to be activated.

#...
au3.WinSetState( "Untitled - Notepad", "", @SW_RESTORE )
au3.WinActivate("Untitled - Notepad", "")
au3.WinWaitActive("Untitled - Notepad", "", 20)
#...

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  
Followers 0