^c produces c

Report problems with documented functionality
loidokaar
Posts: 5
Joined: 30 Jan 2019, 10:36

^c produces c

01 Jun 2020, 03:45

Hi,

I am a big fan of AHK. Thanks to the creators and upkeepers.

I have a small piece of mouse-select-copy to clipboard code (kudo's to authors) which, instead of ^c produces c in about 25% of cases. I have tried Send, SendInput, {Ctrl down}c{Ctrl up} etc and nothing seems to solve the problem. My code:

Code: Select all

#singleinstance force
#UseHook
#InstallMouseHook

#IfWinNotActive ahk_class Net UI Tool Window
#IfWinNotActive ahk_class bosa_sdm_msword

~LButton::

	MouseGetPos x0, y0            ; save start mouse position
	KeyWait LButton
	MouseGetPos x, y              ; position when button released

	If (abs(x-x0) > 10 or abs(y-y0) > 10) {

	clip0 := ClipBoardAll      ; save old clipboard

	ClipBoard =

	;SendInput {Ctrl down}c{Ctrl up}                    ; selection -> clipboard
	Send,^c

	ClipWait 2, 1              ; restore clipboard if no data

	If ErrorLevel

	ClipBoard := clip0

	}

Return

#IfWinNotActive
Should I separate this another .ahk file to ensure reliability? Any other ideas how to make cure CTRL is used before c?

br,
Kaido
User avatar
Yakshongas
Posts: 504
Joined: 21 Jan 2020, 08:41
Facebook: Yakshongas

Re: ^c produces c

02 Jun 2020, 06:04

Try with LControl
Please mark your topics as solved if you don't need any further help. ✅
User avatar
haichen
Posts: 484
Joined: 09 Feb 2014, 08:24

Re: ^c produces c

02 Jun 2020, 06:28

I dont believe there is a Bug in Autohotkey.
May be this helps you:

Code: Select all

#singleinstance force
#InstallMouseHook

~LButton::
savedClip := ClipboardAll
clipboard:=""
MouseGetPos x0, y0 
KeyWait LButton
MouseGetPos x, y
mmoved:= (abs(x-x0) > 10 or abs(y-y0) > 10)

If (mmoved)
{
	Send,^c
	ClipWait, 2
}
else  
	clipboard := savedClip 
Return
loidokaar
Posts: 5
Joined: 30 Jan 2019, 10:36

Re: ^c produces c

13 Jun 2020, 10:34

Try with LControl
Tried. Now less frequent but still happens occasionally. What may be affecting is low memory. I have 8 GB which seems to get fully used by all sorts of nice things (Firefox 700 MB!).

Moving to a separate script (.ahk file) did not help. Should I try to compile?

thanks,
Kaido

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 5 guests