Background commands Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
usser
Posts: 143
Joined: 22 Oct 2014, 13:03

Background commands

Post by usser » 04 Jul 2022, 09:52

Hello

Which GUI interactions can be done in the background i.e. without the window being active?

Thanks!

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Background commands

Post by mikeyww » 04 Jul 2022, 10:46

All of them, because you control the GUI.

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Background commands

Post by Rohwedder » 04 Jul 2022, 10:47

Hallo,
interactions from whom to whom?
An Autohotkey script does not need to "see" its own Guis to be able to interact with them.
With foreign Guis this is more difficult.

usser
Posts: 143
Joined: 22 Oct 2014, 13:03

Re: Background commands

Post by usser » 07 Jul 2022, 14:51

Rohwedder wrote:
04 Jul 2022, 10:47
Hallo,
interactions from whom to whom?
An Autohotkey script does not need to "see" its own Guis to be able to interact with them.
With foreign Guis this is more difficult.
Interactions like:
1) Type 'something' in a minimised Notepad window
2) Open the File menu in a minimised Notepad window
3) Copy the text of a minimised Notepad window
without activating the Notepad window even temporarily (flashing it)

Is that possible?

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Background commands  Topic is solved

Post by Rohwedder » 08 Jul 2022, 01:05

Try:

Code: Select all

SetTitleMatchMode, 2
FileEncoding, UTF-8
FileAppend,, BackGround.txt
IFWinNotExist,% BackGround := "BackGround.txt ahk_exe NotePad.exe"
	Run, "NotePad.exe" "BackGround.txt",, Min
q:: ;Type 'something' in a minimised Notepad window
ControlSend, Edit1, Hello World`n, %BackGround%
Return
w:: ;Copy the text of a minimised Notepad window
ControlGetText, ClipBoard, Edit1, %BackGround%
MsgBox,% ClipBoard
Return
This opens a hidden Notepad window and saves and closes it on ExitApp:

Code: Select all

SetTitleMatchMode, 2
FileEncoding, UTF-8
FileAppend,, BackGround.txt
DetectHiddenWindows, On
Global BackGround := "BackGround.txt ahk_exe NotePad.exe"
IF !WinExist(BackGround)
	Run, "NotePad.exe" "BackGround.txt" ,, Hide
OnExit("SaveBackGround")
q:: ;Type in a hidden Notepad window
ControlSend, Edit1, ^{End}Hello World, %BackGround%
Return
w:: ;Copy the text of a hidden Notepad window
ControlGetText, ClipBoard, Edit1, %BackGround%
MsgBox,% ClipBoard
Return
SaveBackGround()
{
	WinActivate, %BackGround%
	ControlSend, Edit1, ^s, %BackGround% ;store
	WinWaitClose, *%BackGround%
	WinClose, %BackGround% ;close
}

Post Reply

Return to “Ask for Help (v1)”