Gui - Send/paste value while pointer is on another window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DanRim
Posts: 153
Joined: 20 Jul 2018, 15:16

Gui - Send/paste value while pointer is on another window

24 Sep 2020, 10:42

Hi,

Can some GUI specialists tell me how to type/paste any value to the textarea, input field by clicking GUI button?
For example - I am want to send email and already have stored templates in my GUI, I just need to press button and text should appear on textarea there was my cursor before I clicked the button.

Is it possible at all?
In my demo I trying to paste some content by clicking Gui button, but nothing is happening, just getting some error sound/bell that I clicked smth.

Code: Select all


vEdit := "This is content"
Clipboard = vEdit

Gui, Add, Button, y20 w100 vEdit gTemp, Type value

; ***************** Gui Core ******************
Gui, +AlwaysOnTop
Gui, Show, w120 h100										
Gui, Color, Black 											
return

; ***************** Close GUI ******************
GuiClose:													
	ExitApp
	
;~ ; #################################
Temp:
	Send, ^v
	return



A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Gui - Send/paste value while pointer is on another window  Topic is solved

24 Sep 2020, 18:58

DanRim wrote:
24 Sep 2020, 10:42
For example - I am want to send email and already have stored templates in my GUI, I just need to press button and text should appear on textarea there was my cursor before I clicked the button.

Is it possible at all?
Not sure if this is compatible with the way you want your GUI to behave but one possible solution is simply to apply the WS_EX_NOACTIVATE extended style to your GUI - so that it does not become the foreground window when you click it:

Code: Select all

WS_EX_NOACTIVATE := 0x08000000

templates := ["template1", "template2", "template3", "template4"]
index := 1

GUI, New
GUI, +AlwaysOnTop +E%WS_EX_NOACTIVATE%
Gui, Add, UpDown, % "Section vUpDown gUpDownEvent h300 Range1-" . templates.count(), % index
GUI, Add, Text, ys w300 hp vTemplate +Border, % templates[index]
GUI, Add, Button, glabel, send text
GUI, Show, AutoSize NA
return

GuiClose:
ExitApp

UpDownEvent:
	GuiControlGet, index,, UpDown
	GuiControl,, Template, % templates[index]
return

label:
	GuiControlGet, var, %A_GUI%:, Template
	send % "{Text}" . var
return
hope this helps
cheers

A_AhkUser
my scripts
DanRim
Posts: 153
Joined: 20 Jul 2018, 15:16

Re: Gui - Send/paste value while pointer is on another window

25 Sep 2020, 07:31

@A_AhkUser Thank you very much for your example. It does what I need. I updated a little bit to type faster content.
May I ask what is the purpose of those arrows up and down? I tried to manipulate a little bit, but could not see the functionality. By clicking up content just disappears. Why I need that?

By the way, your script has some advance approaching: - what are these WS_EX_NOACTIVATE := 0x08000000 / +E%WS_EX_NOACTIVATE% / and where can i learn more about? Seems really advance.

I really appreciate your help :)

Sharing updated code with clipboard.

Code: Select all

Clipboard := "This is long looong looooooooooooong content `nthis is long looong looooooooooooong content"
WS_EX_NOACTIVATE := 0x08000000

templates := [Clipboard, "template2", "template3", "template4"]
index := 1 ; Choose template stored in array


GUI, New
GUI, +AlwaysOnTop +E%WS_EX_NOACTIVATE%
Gui, Add, UpDown, % "Section vUpDown gUpDownEvent h300 Range1-" . templates.count(), % index
GUI, Add, Text, ys w300 hp vTemplate +Border, % templates[index]
GUI, Add, Button, glabel, send text
GUI, Show, AutoSize NA
return

GuiClose:
ExitApp

UpDownEvent:
	GuiControlGet, index,, UpDown
	GuiControl,, Template, % templates[index]
return

label:
	GuiControlGet, var, %A_GUI%:, Template
	send, ^v
return


A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Gui - Send/paste value while pointer is on another window

25 Sep 2020, 14:24

Hi DanRim,
DanRim wrote:
25 Sep 2020, 07:31
It does what I need.
I am glad to know it!
DanRim wrote:
25 Sep 2020, 07:31
May I ask what is the purpose of those arrows up and down? I tried to manipulate a little bit, but could not see the functionality. By clicking up content just disappears. Why I need that?
You don't necessary need this feature. Arrows are just here for illustrating purpose; in the sample script, they allow to switch between templates' items (the Text control's content is upated by the previous/next item in the array in question each time you click down/up, respectively) - so that one can select from all templates the one want to be sent when the button provided for that purpose on the bottom of the GUI is clicked.
DanRim wrote:
25 Sep 2020, 07:31
what are these WS_EX_NOACTIVATE := 0x08000000 / +E%WS_EX_NOACTIVATE% / and where can i learn more about
Yeah sorry, this is quite abstruse as such. This is described as an Unnamed ExStyle in the documentation - granted not so a commonly used feature. One can also find in the docs common styles usable by both the Gui and GuiControl commands. As for the description of the WS_EX_NOACTIVATE extended style, it can be found in the msdn documentation: Extended Window Styles.
DanRim wrote:
25 Sep 2020, 07:31
I really appreciate your help
Your welcome :) cheers

A_AhkUser
my scripts

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Bing [Bot], CoffeeChaton, DRS and 159 guests