joppertom Posted December 3, 2010 Share Posted December 3, 2010 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}") Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 3, 2010 Share Posted December 3, 2010 Use au3.WinSetState() rather than au3.WinActivate() to restore it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
joppertom Posted December 3, 2010 Author Share Posted December 3, 2010 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}") Link to comment Share on other sites More sharing options...
trancexx Posted December 3, 2010 Share Posted December 3, 2010 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 Link to comment Share on other sites More sharing options...
joppertom Posted December 3, 2010 Author Share Posted December 3, 2010 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}") Link to comment Share on other sites More sharing options...
joppertom Posted December 3, 2010 Author Share Posted December 3, 2010 It was Notepad that was the problem. The code behaves very well with WordPad. Thank you, Tom Link to comment Share on other sites More sharing options...
joppertom Posted December 3, 2010 Author Share Posted December 3, 2010 Hmmm, I didn't try that! Perhaps on Monday. 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) #... 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