Page 1 of 1

GUI: input to text file?

Posted: 31 Mar 2019, 13:55
by Bernd
Hi, so I am in a text file (.txt, Word, browser window...) and I have created a Gui.
How do I trigger the Gui (which is now in focus) to send text *back to my text file* (instead of the Gui's own edit field)?
Is there something like "second last window in focus"?

Re: GUI: input to text file?

Posted: 31 Mar 2019, 16:00
by toralf
Iirc there is something like a z order. You might search for this on this forum.

Re: GUI: input to text file?

Posted: 01 Apr 2019, 06:07
by uname
Assuming the Gui is created by your script - Just use:

Code: Select all

Gui, Show, NoActivate

Re: GUI: input to text file?

Posted: 01 Apr 2019, 15:20
by Bernd
Thanks @uname, tried it but it did not work.

What I want to do is basically copy the Word symbol manager. I click a button in the Gui with "@" on it and @ appears in the Word document.

Re: GUI: input to text file?

Posted: 01 Apr 2019, 15:35
by Bernd
OK, I managed it with:

Gui, Hide
Send, @
Gui, Show
return

But is there some better way to do it?

Re: GUI: input to text file?

Posted: 01 Apr 2019, 16:09
by garry
example send from GUI to WordPad

Code: Select all

pr=wordpad.exe
sc=ahk_exe WORDPAD.EXE

#NoEnv
#Warn
setworkingdir,%a_scriptdir%
SendMode Input
FileEncoding, UTF-8
Gui,1: -DPIScale
SS_REALSIZECONTROL := 0x40
Gui,1:Font,s13 cGray,Lucida Console
Gui,1:Color,Black,Gray
Gui,1:add,button ,x10  y10 h35 w100 ga1,@
Gui,1:add,button ,x130 y10 h35 w100 ga2,Ø
Gui,1:show, x10 y50 w500 h100,Send2wordpad
return
Guiclose:
exitapp

a1:
Gui,1:submit,nohide
gosub,check
;sendinput, % "{raw}@"
send,{text}@
return

a2:
Gui,1:submit,nohide
gosub,check
;sendinput, % "{raw}Ø"
send,{text}Ø
return

check:
IfWinNotExist,%sc%
 {
 Run, %pr%,,,pid2
 WinWait,%sc%
 }
IfWinNotActive ,%sc%,,WinActivate,%sc%
    WinWaitActive,%sc%
return

Re: GUI: input to text file?

Posted: 01 Apr 2019, 17:42
by Bernd
Thank you @garry.
However, I want to be able to sent my characters to *any* text window (.txt, Word, browser window...), whatever I click last.
The question is, can I do this more elegantly than with Gui, Hide/Show? It always makes my Gui flicker.

Re: GUI: input to text file?

Posted: 02 Apr 2019, 02:02
by garry
If use GUI-button, the GUI is active ...
example with Hotkey

Code: Select all

;- GroupAddx
SetTitleMatchMode, 2
GroupAdd, myPr, Mozilla Firefox
GroupAdd, myPr, Google Chrome
GroupAdd, myPr, Editor
GroupAdd, myPr, Notepad++ 

#IfWinActive, ahk_group myPr
F9::
send,{text}@
return
#IfWinActive

;- or 


f8::
send,{text}@
return

Re: GUI: input to text file?

Posted: 02 Apr 2019, 12:02
by garry
@Bernd
However, I want to be able to sent my characters to *any* text window (.txt, Word, browser window...), whatever I click last.
The question is, can I do this more elegantly than with Gui, Hide/Show? It always makes my Gui flicker :
Gui, Hide
Send, @
Gui, Show
return
I had no answer how to send from GUI to any text window ... if click GUI-button the GUI is active and doesn't send ....