Alternative to copy/paste Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Shadowless422
Posts: 2
Joined: 14 Sep 2020, 05:21

Alternative to copy/paste

14 Sep 2020, 07:22

Hello to everyone, I'm new to this community and this is my first post, so thank you all in advance for the replies! :D
I'm asking you help about something I didn't find a solution for anywhere: an alternative way to copy/paste text using AHK.
This is the scenario: you are using an application that uses the classic copy/paste (Ctrl + C, Ctrl + V) and select-all (Ctrl + A) keybindings as hotkeys for some functions and you can't use the mouse to right-click on the text. In a situation like this, it is of course impossible to select-all, copy, and paste text like you normally would do, but I was thinking about using AutoHotKey to do something like this:
  • using an hotkey (or a specific keyword, like _copy:) you tell to the script to start to record what you write;
  • using another hotkey (or another specific keyword, or, even better, the same hotkey/keyword) to make AHK to stop recording;
  • using another hotkey/keyword to "paste" (type automatically, maybe using the function send, or something like that) the saved text from the previous steps.
Sorry if the post was heavy to read, I tried to be as concise as I could. I'm asking you how could I translate this to code, even partially, since i have no clue on how I can record a phrase.
I'm totally open to any solution, even if it completely differs from what I thinked about (maybe there's a way to save directly what you just wrote on a textbox without telling the script when to start and when to stop).
As I said at the beginning, thanks in advance :)
gregster
Posts: 5213
Joined: 30 Sep 2013, 06:48

Re: Alternative to copy/paste  Topic is solved

14 Sep 2020, 07:38

There are probably many ways to do something like you have in mind - for example:

Code: Select all

^u::
tooltip, Recording
Input, var, v, % Chr(21)		; Chr(21) stands for Ctrl+u
tooltip
return

^q::Sendinput % var
Type Ctrl+u to start and stop recording (a tooltip indicates that it is recording).
Use Ctrl+q to send the recorded string (depending on the target application, other send modes or additional options might be necessary, like {text}).

You could also use a string like _copy to start recording (or to paste) - by using a hotstring.
Shadowless422
Posts: 2
Joined: 14 Sep 2020, 05:21

Re: Alternative to copy/paste

14 Sep 2020, 10:42

gregster wrote:
14 Sep 2020, 07:38
There are probably many ways to do something like you have in mind - for example:

Code: Select all

^u::
tooltip, Recording
Input, var, v, % Chr(21)		; Chr(21) stands for Ctrl+u
tooltip
return

^q::Sendinput % var
Type Ctrl+u to start and stop recording (a tooltip indicates that it is recording).
Use Ctrl+q to send the recorded string (depending on the target application, other send modes or additional options might be necessary, like {text}).

You could also use a string like _copy to start recording (or to paste) - by using a hotstring.
This is working greatly! Thank you a lot!
In case someone needs a version with hotstrings, here's the code I'm currently using:

Code: Select all

:*:<c::
tooltip, Recording
Input, var, v, {Enter}	
tooltip
return

:*:<v::
Sendinput % var
return
So when I type <c it start recording and stops whenever I hit Enter, and when I type <v it writes the recorded text.

Have a great day!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], wineguy, WuffTheCoder and 40 guests