Probably a silly question with an easy answer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mhermon
Posts: 5
Joined: 02 Jun 2020, 08:36

Probably a silly question with an easy answer

02 Jun 2020, 08:52

I'm using AHK for very basic hot key creation of things I type sometimes hundreds of times a day and i am trying to figure out how to insert clipboard content into my hotkey

example
perform X on Y;sleep 60;perform Z on Y

The "y" changes while everything else stays the same, can I automatically insert clipboard content for y? I've read the documentation for clipboard and clipboardall but that seems to be for more complex scripting (either that or I just dont understand how it works in my scenario)

Is what I'm trying to do possible in a basic hotkey phrase or do i need to do it via script?
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Probably a silly question with an easy answer

02 Jun 2020, 09:20

Even a single basic hotkey phrase is executed using a script. So, yes.
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Probably a silly question with an easy answer

02 Jun 2020, 09:21

so u want a hotkey to insert the phrase
perform X on Y;sleep 60;perform Z on Y
, where Y is the contents of ur Clipboard?

Code: Select all

q::Send % "{Text}perform X on " Clipboard ";sleep 60;perform Z on " Clipboard
press q
mhermon
Posts: 5
Joined: 02 Jun 2020, 08:36

Re: Probably a silly question with an easy answer

02 Jun 2020, 09:31

BNOLI wrote:
02 Jun 2020, 09:20
Even a single basic hotkey phrase is executed using a script. So, yes.
Yeah, I understand that, just didnt know how to present it any other way. Based on the example above, I've just been doing it wrong :) and I'm about to up my AHK game.
mhermon
Posts: 5
Joined: 02 Jun 2020, 08:36

Re: Probably a silly question with an easy answer

02 Jun 2020, 09:38

swagfag wrote:
02 Jun 2020, 09:21
so u want a hotkey to insert the phrase
perform X on Y;sleep 60;perform Z on Y
, where Y is the contents of ur Clipboard?

Code: Select all

q::Send % "{Text}perform X on " Clipboard ";sleep 60;perform Z on " Clipboard
press q
Thank you for the example, looks like I can improve a lot of my basic AHKs. I was just not using the right option for what I was trying to do. I was just using text expansion

Code: Select all

::;q;;perform X on Y;sleep 60;perform Z on Y
mhermon
Posts: 5
Joined: 02 Jun 2020, 08:36

Re: Probably a silly question with an easy answer

02 Jun 2020, 10:37

swagfag wrote:
02 Jun 2020, 09:21
so u want a hotkey to insert the phrase
perform X on Y;sleep 60;perform Z on Y
, where Y is the contents of ur Clipboard?

Code: Select all

q::Send % "{Text}perform X on " Clipboard ";sleep 60;perform Z on " Clipboard
press q
Hope you dont mind another question, the script example you provided does exactly what it should. how do I prevent it from executing every time I press the trigger? I used p instead of q. I tried to make it use a 3 letter trigger, which is how my basic text expansion was triggered but that doesn't appear to work

Code: Select all

::;pmp::pimp -x target;sleep 60;pimp -o target
so typing ;pmp resulted in pimp -x target;sleep 60;pimp -o target being output to my terminal.

With the script every time I enter p it outputs the contents of the script, which is obviously going to result in a lot of backspacing or disabling the script.

I tried using p & m so it requires both keys to be pressed but it breaks the script.

If you can just point in the right direction in the documentation I can likely figure it out
mhermon
Posts: 5
Joined: 02 Jun 2020, 08:36

Re: Probably a silly question with an easy answer

02 Jun 2020, 11:01

I figured out a way to get it to work, not sure if it is the "right" way, but it works.

I just use ^p to trigger the script instead of p

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: a_riva, peter_ahk and 178 guests