GUI: input to text file?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Bernd
Posts: 56
Joined: 03 Sep 2016, 13:56

GUI: input to text file?

31 Mar 2019, 13:55

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"?
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: GUI: input to text file?

31 Mar 2019, 16:00

Iirc there is something like a z order. You might search for this on this forum.
ciao
toralf
User avatar
uname
Posts: 23
Joined: 25 Oct 2013, 12:50

Re: GUI: input to text file?

01 Apr 2019, 06:07

Assuming the Gui is created by your script - Just use:

Code: Select all

Gui, Show, NoActivate
Bernd
Posts: 56
Joined: 03 Sep 2016, 13:56

Re: GUI: input to text file?

01 Apr 2019, 15:20

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.
Bernd
Posts: 56
Joined: 03 Sep 2016, 13:56

Re: GUI: input to text file?

01 Apr 2019, 15:35

OK, I managed it with:

Gui, Hide
Send, @
Gui, Show
return

But is there some better way to do it?
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: GUI: input to text file?

01 Apr 2019, 16:09

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
Bernd
Posts: 56
Joined: 03 Sep 2016, 13:56

Re: GUI: input to text file?

01 Apr 2019, 17:42

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.
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: GUI: input to text file?

02 Apr 2019, 02:02

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
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: GUI: input to text file?

02 Apr 2019, 12:02

@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 ....

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Google [Bot], inseption86, jaka1 and 296 guests