Copy to clipboard after clicking OK

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ndiaz
Posts: 73
Joined: 10 Jan 2017, 17:05
Contact:

Copy to clipboard after clicking OK

13 Mar 2019, 13:36

Hello,

I need some help to create an action that will send a copy to clipboard command after clicking an OK button that closes a window. The ClassNN is TButton2.

I was trying with Lbutton as the hotkey, but I can't figure out how to limit the left click to the OK button.

Thank you in advance!
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Copy to clipboard after clicking OK

19 Mar 2019, 00:05

Hi.
Pressing a button is not difficult. Look here.
Sending a value to clipboard is even easy too. You can send a ^c by example SendInput ^c or store the value of a variable by using clipboard := myVariable.

Your code can look like below

Code: Select all

Control, Check, , TButton2, ahk_class ReplaceThisWithYourAHK_ClassOrWindowTitle
clipboard := "" ; make clipboard empty to be able to monitor the content with CLIPWAIT
send ^c
Clipwait, 2 ; 
As I don't know, from where you will get content to store in clipboard, I can't give reliable support.
Einfach nur ein toller Typ. :mrgreen:
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Copy to clipboard after clicking OK

19 Mar 2019, 10:08

Here's an idea:

Code: Select all

#NoEnv
#SingleInstance force
#Warn

GUI, Add, Button, w100 h200, OK1
GUI, Add, Button, w100 h200, OK2
GUI, Add, Button, w100 h200, OK3
GUI, Show, AutoSize, TEST
i := 0
return

#If MouseGetWinControl("TEST ahk_class AutoHotkeyGUI", "Button2")
	~LButton::ToolTip % ++i
#If

MouseGetWinControl(_winTitle:="", _classNN:="") {
	MouseGetPos,,, _hWin, _hwnd, 2
	ControlGet, _controlID, Hwnd,, % _classNN, % "ahk_id " . WinExist(_winTitle . " ahk_id " . _hWin)
return (_hwnd && (_hwnd = _controlID))
}
my scripts

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RandomBoy, Theda and 266 guests