qwert Posted June 21, 2014 Share Posted June 21, 2014 I have the $hWnd of the window that was active when my script gained focus. Now I need to reactivate that window and fetch any text that was highlighted. The problem is that every activation command I've tried deselects the highlighted text in the other window. Yet, if I manually click on the taskbar entry, the window activates with the text still highlighted. I've tried various combinations of WinActivate($otherTask) ... WinSetState($otherTask, "", @SW_SHOW) ... _WinAPI_SetFocus ($otherTask) ... and even just disabling my own script with WinSetState($thisTask, "", @SW_DISABLE) Nothing has worked ... and I've read 7 years of posts looking for a way. Is there a way to emulate a taskbar selection? Thanks in advance for any help. Link to comment Share on other sites More sharing options...
Danp2 Posted June 21, 2014 Share Posted June 21, 2014 What about _WinAPI_SwitchToThisWindow? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Malkey Posted June 21, 2014 Share Posted June 21, 2014 This example works for me even when the highlighted text is in a minimized window. Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ; Note:- Before running this script from the SciTE window, highlight some text in the "AutoIt Help" window to be copied. ClipPut("") ; Empty clipboard WinActivate("AutoIt Help") WinWaitActive("AutoIt Help") Send("^c") ; Copy highlighted text in active window to clipboard. ; -------- Display clipboard --------- WinActivate(ControlGetHandle("[Class:SciTEWindow]", "", "Scintilla2")) Send("^v") Send("{ENTER}") ;or ConsoleWrite(ClipGet() & @LF) Link to comment Share on other sites More sharing options...
qwert Posted June 22, 2014 Author Share Posted June 22, 2014 Thanks for the responses. After several changes, _WinAPI_SwitchToThisWindow seems to work best in the particular script I'm working with (sending character strings window-to-window). The new issue I'm facing is how to maintain focus on the target window during a series of Send operations. There seems to be a timing window where focus is momentarily back on my script's GUI, such that the next Send fails. Link to comment Share on other sites More sharing options...
Danp2 Posted June 22, 2014 Share Posted June 22, 2014 Is there a reason why you can't use ControlSend? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
qwert Posted June 22, 2014 Author Share Posted June 22, 2014 My understanding is that ControlSend requires knowledge of the controls in the target window ... which I don't have. An example would be sending text to cells in a spreadsheet. 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