AutoHotkey Community

It is currently May 27th, 2012, 12:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: June 13th, 2005, 10:08 pm 
Offline

Joined: June 9th, 2005, 4:20 pm
Posts: 21
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)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2005, 11:59 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
I might be misunderstanding the issue but will any of these help? ControlSend, ControlSetText, ControlGetText


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2005, 5:09 pm 
Offline

Joined: June 9th, 2005, 4:20 pm
Posts: 21
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Exabot [Bot], Google Feedfetcher, jrav and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group