Sharemouse and AHK: how to repeat Ctrl+W keypresses? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
llinfeng
Posts: 86
Joined: 08 Dec 2016, 21:54
Contact:

Sharemouse and AHK: how to repeat Ctrl+W keypresses?

04 Feb 2020, 21:09

Sharemouse is a very expensive piece of software that help people use "local" mouse + keyboard on "remote" computers. Across two Windows 10 machines running exactly the same AutoHotKey script, on the "remote" computer, I cannot repeat Ctrl+W mappings when repeatedly pressing "w" key while holding Ctrl button down. This applies to all my other Ctrl+something mappings.

Code: Select all

^w:: Send ^+{Left}{BS}
^h::Send {BS}
Here is the log on the local machine, with key-sequence: F5, Hold down Ctrl, w, w, Lift Ctrl, F5.

Code: Select all

 
74  03F	 	d	12.42	F5             	
74  03F	 	u	0.09	F5             	
01  000	 	d	0.59	LButton        	
01  000	 	u	0.14	LButton        	
A2  01D	 	d	0.44	LControl       	
57  011	h	d	0.09	w              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.01	LShift         	
25  14B	i	d	0.02	Left           	
25  14B	i	u	0.00	Left           	
A0  02A	i	u	0.02	LShift         	
A2  01D	i	u	0.01	LControl       	
A2  01D	i	d	0.02	LControl       	
57  011	s	u	0.00	w              	
A2  01D	i	u	0.11	LControl       	
08  00E	i	d	0.00	Backspace      	
08  00E	i	u	0.00	Backspace      	
A2  01D	i	d	0.02	LControl       	
57  011	h	d	0.16	w              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.02	LShift         	
25  14B	i	d	0.01	Left           	
25  14B	i	u	0.00	Left           	
A0  02A	i	u	0.02	LShift         	
A2  01D	i	u	0.02	LControl       	
A2  01D	i	d	0.01	LControl       	
57  011	s	u	0.02	w              	
A2  01D	i	u	0.09	LControl       	
08  00E	i	d	0.00	Backspace      	
08  00E	i	u	0.00	Backspace      	
A2  01D	i	d	0.01	LControl       	
A2  01D	 	u	0.00	LControl       	
74  03F	 	d	1.92	F5  
Here is the log on the remote machine, with key-sequence: F5, Hold down Ctrl, w, w, w, Lift Ctrl, F5.

Code: Select all

74  03F	a	d	4.01	F5             	
74  03F	a	u	0.09	F5             	
A2  01D	a	d	0.72	LControl       	
57  011	h	d	0.14	w              	
A2  01D	i	d	0.02	LControl       	
A0  02A	i	d	0.02	LShift         	
25  14B	i	d	0.01	Left           	
25  14B	i	u	0.00	Left           	
A0  02A	i	u	0.02	LShift         	
A2  01D	i	u	0.02	LControl       	
57  011	a	u	0.00	w              	
57  011	a	d	0.11	w              	
08  00E	i	d	0.02	Backspace      	
08  00E	i	u	0.00	Backspace      	
57  011	a	u	0.05	w              	
57  011	a	d	0.11	w              	
57  011	a	u	0.08	w              	
A2  01D	a	u	0.05	LControl       	
74  03F	a	d	0.34	F5   
This post mentioned a solution having to do with Hooks. I followed the solution and updated the AHK script on both machines of mine. Yet, nothing change: repeatedly pressing w while holding down Ctrl only execute the mapping upon the first keypress of W, and will send wwwwwww afterward. Disabling AHK script on the local machine does not help solve this problem.

Also, the following mid-mouse-click tweak for Thinkpad Trackpoint failed. It "blocks" the middle-mouse-click event on the "remote" machine. As discussed in its source, the script is meant for replicating Thinkpad Trackpoint's scrolling action while preserving the middle-click function. On the local machine, everything worked as intended. While disabling the local AHK script, the middle-mouse-click is activated properly on the remote machine. (Single middle-mouse-click events on the remote machine are blocked completely when AHK script is activated on the local machine, regardless of which keyboard/mouse I use. Single-click of MButton appears to do nothing at all through Sharemouse.)

Code: Select all

; Midbutton down for scrolling {{{
; Feature: with acceleration as intended.
; Source: http://forum.notebookreview.com/threads/ultranav-middle-click-button-scroll.423415/
; Linking source: ettps://superuser.com/questions/91074/thinkpad-trackpoint-scrolling-and-middle-click-possible
; Working version {{{
$*MButton::
Hotkey, $*MButton Up, MButtonup, off
KeyWait, MButton, T0.2
If ErrorLevel = 1
{
	Hotkey, $*MButton Up, MButtonup, on
	MouseGetPos, ox, oy
 	SetTimer, WatchTheMouse, 5
	SystemCursor("Toggle")
}
Else
	Send {MButton}
return
MButtonup:
Hotkey, $*MButton Up, MButtonup, off
SetTimer, WatchTheMouse, off
SystemCursor("Toggle")
return
WatchTheMouse:
MouseGetPos, nx, ny
dy := ny-oy
dx := nx-ox
If (dx**2 > 0 and dx**2>dy**2) ;edit 4 for sensitivity (changes sensitivity to movement)
{
	times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal)
	Loop, %times%
	{
		If (dx > 0)
			Click WheelRight
		Else
			Click WheelLeft
   	}
}
If (dy**2 > 0 and dy**2>dx**2) ;edit 0 for sensitivity (changes sensitivity to movement)
{
	times := Abs(dy)/1 ;edit 1 for sensitivity (changes frequency of scroll signal)
	Loop, %times% 
	{
		If (dy > 0)
			Click WheelDown
		Else
			Click WheelUp
	}   
}
MouseMove ox, oy
return
SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
    static AndMask, XorMask, $, h_cursor
        ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
        , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
        , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
    if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
    {
        $ = h                                          ; active default cursors
        VarSetCapacity( h_cursor,4444, 1 )
        VarSetCapacity( AndMask, 32*4, 0xFF )
        VarSetCapacity( XorMask, 32*4, 0 )
        system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
        StringSplit c, system_cursors, `,
        Loop %c0%
        {
            h_cursor   := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
            h%A_Index% := DllCall( "CopyImage",  "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
            b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
                , "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
        }
    }
    if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
        $ = b  ; use blank cursors
    else
        $ = h  ; use the saved cursors
    Loop %c0%
    {
        h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
        DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
    }
}
; }}}
; }}}
Please advise how to proceed with getting AHK to work properly on the "remote" computer through Sharemouse. In particular, for Ctrl+W, it is working just fine outside of AHK ==> With multiple File Explorers opened, holding down Ctrl and pressing W multiple times does get all those Explorer windows closed one-by-one. Repeating W with Ctrl pressed down in the console emulators (ConEmu, wsltty, Windows Terminal (Preview)) is also working as intended ---- deleting words to the left one-by-one.
llinfeng
Posts: 86
Joined: 08 Dec 2016, 21:54
Contact:

Re: Sharemouse and AHK: how to repeat Ctrl+W keypresses?  Topic is solved

09 Jun 2021, 22:13

Thanks to user @ShambleS1980 on the AutoHotkey discord channel, a quick solution is revealed.

Code: Select all

    ^w:: send {blind}^{bs}
Here, the {blind} prefix makes sure the modifier key (Ctrl) is held down until it is released deliberately. This helped to restore the "normal" behavior on the remote machine controlled through the KVM software.

PS: a new list of KVM software - Barrier is free, so is Mouse without Borders.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Mateusz53, mikeyww, MrHue and 279 guests