double click after paste

Get help with using AutoHotkey and its commands and hotkeys
mikagenic
Posts: 64
Joined: 16 Sep 2014, 18:26

double click after paste

26 Sep 2016, 20:37

I have the following script that selects the word at the cursor, pastes over it and then selects the current word

NumpadAdd::
CoordMode, Caret, Screen
CoordMode, Mouse, Screen
MouseGetPos, X_1, Y_1, ID_1, Control_1
MouseMove, %A_CaretX%, %A_CaretY% ; move mouse to caret pos
Click 2 ; select word
Send, ^v ; paste
Click 2 ; select word
MouseMove, %X_1%, %Y_1% ; restore mouse
Return

the paste happen correctly but the current word does not get selected
that is the second Click 2 does not work
why ? any help ?
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: double click after paste

26 Sep 2016, 21:07

Try slowing it down with a Sleep 100 before the second Click 2.
mikagenic
Posts: 64
Joined: 16 Sep 2014, 18:26

Re: double click after paste

26 Sep 2016, 21:30

I did, no luck even with a big sleep
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: double click after paste

26 Sep 2016, 22:40

Hi, If you want to select the word at the cursor, paste over it and then select the word you just pasted try this:
Change the 1st "Click 2" line to "send, ^+{right}" and the 2nd to "send, ^+{left}" no quotes.
If you want the word after the one you just pasted change the "^+{left}" to "^+{right}" no quotes.

hunter99
mikagenic
Posts: 64
Joined: 16 Sep 2014, 18:26

Re: double click after paste

27 Sep 2016, 00:40

hynter99, ctrl left right ietc s not what I want, it ends up selecting an extra space at the end of the word which is why the dbl click trick

But why is my code not working ?
why is the second Click 2 ignored ?
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

Re: double click after paste

27 Sep 2016, 01:13

Perhaps the caret is placed after your word, try to subtract some pixels from the x-coord and perhaps add a few to the y-coord.
mikagenic
Posts: 64
Joined: 16 Sep 2014, 18:26

Re: double click after paste

27 Sep 2016, 18:46

thx Helgef, that didn't work, and also having the caret after the word should still highlight it on double click
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

Re: double click after paste

28 Sep 2016, 03:22

This works for me in notepad++. I also added SetDefaultMouseSpeed,0, it is not needed if you don't want it.

Code: Select all

SetDefaultMouseSpeed,0
NumpadAdd::
CoordMode, Caret, Screen
CoordMode, Mouse, Screen
MouseGetPos, X_1, Y_1, ID_1, Control_1 
Click %A_CaretX%, %A_CaretY%,2 ; select word
Send, ^v ; paste
x:=A_CaretX-5
y:=A_CaretY+5
Click %x%, %y%,2 ; select word
MouseMove, %X_1%, %Y_1% ; restore mouse 
Return
If you have problems, try adding a sleep as suggested earlier. Note that the caret positions are not reported accurately by all windows.
mikagenic
Posts: 64
Joined: 16 Sep 2014, 18:26

Re: double click after paste

28 Sep 2016, 21:48

works great ! thanks you

Return to “Ask For Help”

Who is online

Users browsing this forum: anon11235813, Bing [Bot], rcmosher, teadrinker and 55 guests