AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Switching focus from external GUI button to target window

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
dragonfly



Joined: 09 Jun 2005
Posts: 18

PostPosted: Mon Jun 13, 2005 9:08 pm    Post subject: Switching focus from external GUI button to target window Reply with quote

I have a GUI (not created in AHK) which has an array of buttons to pass different parameters into an AHK script.

Example: to cut highlighted text from an editor and parse the text and return to editor.

Problem I have .. the external GUI is in focus when clicking the button and the target Window (editor with highlighted text) is out of focus.

So the Send, ^X command will not cut the text in the target (out of focus) Window with highlighted text.

I can't see (reading the various Focus commands) how to switch focus from the external in-focus GUI to bring the target window into focus immediately upon clicking button in external GUI.

Is one answer to build the GUI inside AHK rather than having a second GUI window (although I would prefer to use an external GUI)?
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Mon Jun 13, 2005 10:59 pm    Post subject: Reply with quote

I might be misunderstanding the issue but will any of these help? ControlSend, ControlSetText, ControlGetText
Back to top
View user's profile Send private message Visit poster's website
dragonfly



Joined: 09 Jun 2005
Posts: 18

PostPosted: Tue Jun 14, 2005 4:09 pm    Post subject: Reply with quote

Thanks for the suggestion .. I'm still learning the subtle use of other Commands.

....

I got the script to work by using this preamble ....

Code:

; preamble

#SingleInstance force
SetTitleMatchMode, 2  ; partial match

; set GUI out of focus and EditPlus into focus
WinSet, Bottom,, Text Filter Selector ; set the bottom status of GUI
Sleep, 200
WinSet, AlwaysOnTop, On, EditPlus ; set the always-on-top status of EditPlus
Sleep, 200


; trace active window stats (use only for debugging)
WinGetActiveStats, Title, Width, Height, X, Y
MsgBox, on entry - The active window "%Title%" is %Width% wide`, %Height% tall`, and positioned at %X%`,%Y%.


; ... rest of code to cut and paste in active EditPlus window ..




The effect of WinSet was to switch the GUI out of focus, and the EditPlus window into focus before hitting the Send, ^x and Send, ^v code lines in the script.

The trace WinGetActiveStats was useful for inspecting the active window at the point of cutting and pasting; and sure enough, without the WinSet preamble the GUI was still in focus. The preamble script solved this.

...

One point I noted that when using

SetTitleMatchMode, 2 ; partial match

I had to be careful to ensure that two windows did not contain the same fragment of title, so causing confusion. e.g. I had title fragment "EditPlus" in bother EditPlus and also in the GUI Title, and had to change GUI Title to remove reference to EditPlus.

...

I did experiment with use of ControlSend as suggested.

ControlSend, AfxFrameOrView42s1, ^x, EditPlus ; cut highlighted text

where "Now Mouse Under Cursor" = AfxFrameOrView42s1 (in EditPlus)

This worked. But I got similar control by WinSet preamble code.

And I'm not sure if the Value AfxFrameOrView42s1 might change in different configurations/releases of EditPlus. "Send" is more general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group