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 ?
double click after paste
Re: double click after paste
Try slowing it down with a Sleep 100 before the second Click 2.
Re: double click after paste
I did, no luck even with a big sleep
Re: double click after paste
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
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
Re: double click after paste
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 ?
But why is my code not working ?
why is the second Click 2 ignored ?
Re: double click after paste
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.
Re: double click after paste
thx Helgef, that didn't work, and also having the caret after the word should still highlight it on double click
Re: double click after paste
This works for me in notepad++. I also added SetDefaultMouseSpeed,0, it is not needed if you don't want it.
If you have problems, try adding a sleep as suggested earlier. Note that the caret positions are not reported accurately by all windows.
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
Re: double click after paste
works great ! thanks you
Who is online
Users browsing this forum: Aqualest, Bing [Bot], jdfnnl, serenite, yanjujino1 and 324 guests