Selecting, copying, and pasting text conveniently

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Selecting, copying, and pasting text conveniently

12 Aug 2018, 11:18

Hi all,

I have just started using AHK and have little or no idea about scripts. What I am trying to do is apparently simple:

I copy and paste lots of text from websites and programs and would like to have the same way of selecting text as in MS Word (selecting one or more words without positioning the cursor at the beginning or end of a word). Besides, two added functions.

1) Automatic copy of the word/words once selected.
2) Pasting the text by just middle clicking the mouse on the desired position.

Please can you help me with this? It would be much appreciated!
pro100andrik94
Posts: 27
Joined: 08 Aug 2018, 07:27

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 02:38

For copying selected word you can use this script.
For pasting text this

Code: Select all

~MButton::
click
send ^v 
return
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 06:36

Thank you. The paste function works as expected but not the first one.

What I would like is to select text like in MS Word, i.e. placing the cursor in any part of the word and dragging selects the whole word, if you continue dragging the next whole word is selected, and so on.

Is there any way to do this?
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 07:29

Code: Select all

~LButton:: 
Click, down
while GetKeyState("LButton")
{
}
send ^c
return

~MButton::
click
send ^v 
return
But you might also want to have a suspend key that will stop the whole click function. It works but its a little weird.
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 10:53

Amzaing MannyKSoSo, it works!

Yeah, sometimes it feels weird, but overall it´s very good. I can suspend the function pressing letf control.

I´ll see if it can be improved somehow.

Thanks a lot!
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 12:41

If you want a bit more refined version then here it is

Code: Select all

~LButton::
Sleep 200
If GetKeyState("LButton", "P")
{
	Click, Down
	While GetKeyState("LButton") {
	}
	send ^c
	Return
}
Else
	Return
This waits 200 milliseconds and if you are still holding down the button it will work like word otherwise its just a normal click.
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Re: Selecting, copying, and pasting text conveniently

13 Aug 2018, 15:53

Hi,

The last script works OK with word like mode but "normal" mode behaves weirdly.
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Re: Selecting, copying, and pasting text conveniently

14 Aug 2018, 03:31

Actually, it is a good approach to have the option to activate Word like mode. Any idea how to make it work correctly?
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Selecting, copying, and pasting text conveniently

14 Aug 2018, 07:06

I think the best bet is using a hotkey for Pause here https://autohotkey.com/docs/commands/Pause.htm
Set it above the ~LButton:: and it "should" pause the script from that action. The reason why the last script behaves a little weird is because you have to hold down the button for at least 200 ms before its registered as a word select. You can adjust the sleep to your liking but 200 is about as long as it should be. You also don't want the script to be too short of a time either otherwise it will just take all clicks as the word click.
Suspend is also another option if Pause does not work https://autohotkey.com/docs/commands/Suspend.htm
krpi
Posts: 6
Joined: 11 Aug 2018, 06:47

Re: Selecting, copying, and pasting text conveniently

14 Aug 2018, 10:31

I prefer not to use key combinations as it makes the process slower. I have added the paste function to your second script. There are some flaws but I think I can live with them :)

If you come up with a better idea without hotkeys, please let me know.

Thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 210 guests