Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerToys "Paste As Plain Text" not working correctly when using EPKL #83

Open
ToastedLion opened this issue Feb 26, 2024 · 4 comments
Open
Labels
answered Guru covered (most of) the issue duplicate Attack Of The Clones

Comments

@ToastedLion
Copy link

Hi DreymaR!

Thank you for all of your work on this awesome tool.

I'm having trouble using PowerToys "Paste As Plain Text" the way I want to when EPKL is active. I use PowerToys "Paste As Plain Text" with Ctrl + Shift + V as the shortcut. With EPKL disabled, this works as expected across apps. With EPKL enabled and PowerToys "Paste As Plain Text" disabled, Ctrl + Shift + V works as expected in applications that natively implement that shortcut, and has no effect in applications that don't (i.e. expected behavior for this configuration). With EPKL enabled and PowerToys "Paste As Plain Text" enabled, Ctrl + Shift + V has inconsistent results: most often, it outputs "V", sometimes it pastes as plain text as expected, and occasionally it has no effect. All three of these happen with some frequency regardless of whether the active application natively implements this shortcut.

If I use an eD layout and comment out the line QW_V = V 1 v V -- ÷ γ in BaseLayout_Cmk-eD.ini, then once again, PowerToys "Paste As Plain Text" works as expected. If I use a VK layout and comment out the line QW_V = V VirtualKey in BaseLayout_Cmk-VK.ini, again, PowerToys "Paste As Plain Text" works as expected.

Below is the output of the key history when I get "V'. It always looks approximately like this, and fills up the default 50 lines however quickly I try to press and release all the keys.

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A0  02A	h	u	0.00	LShift         	
A2  01D	a	d	0.02	LControl       	
56  02F	h	d	0.00	v              	
A0  02A	i	d	0.00	LShift         	
56  02F	h	u	0.00	v              	
A2  01D	a	u	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
A0  02A	i	u	0.00	LShift         	
A0  02A	i	d	0.00	LShift         	
A0  02A	h	d	0.00	LShift         	
A2  01D	i	d	0.01	LControl       	
A0  02A	i	d	0.00	LShift         	
56  02F	i	d	0.00	v              	
FF  000	a	u	0.00	not found      	
A2  01D	a	u	0.00	LControl       	
A0  02A	h	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
56  02F	h	d	0.00	v              	
56  02F	h	u	0.00	v              	
56  02F	i	u	0.00	v              	
A2  01D	a	u	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
A2  01D	i	d	0.00	LControl       	
A0  02A	h	d	0.02	LShift         	
A0  02A	i	d	0.00	LShift         	
A2  01D	i	u	0.00	LControl       	
56  02F	i	d	0.00	v              	
A0  02A	i	u	0.00	LShift         	
56  02F	i	u	0.00	v              	
A0  02A	i	d	0.00	LShift         	
56  02F	h	u	0.09	v              	
56  02F	i	u	0.00	v              	
A2  01D	 	u	0.01	LControl       	
A0  02A	h	u	0.00	LShift         	
A0  02A	i	u	0.50	LShift         	
74  03F	h	d	4.41	F5             	C:\[...]\EPKL_Executable_v1-4-1\EPKL.exe
74  03F	i	d	0.00	F5 

Below is the output of the key history when I get the expected "paste as plain text" behavior. In this case the default key history fully captures the key sequence.

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------       	
0D  01C	h	u	0.11	Enter          	
0D  01C	i	u	0.00	Enter          	
A2  01D	 	d	0.06	LControl       	
A0  02A	h	d	0.30	LShift         	
A0  02A	i	d	0.00	LShift         	
56  02F	h	d	0.31	v              	
56  02F	i	d	0.00	v              	
FF  000	a	u	0.00	not found      	
A2  01D	a	u	0.00	LControl       	
A0  02A	h	u	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
56  02F	h	d	0.02	v              	
A0  02A	i	u	0.00	LShift         	
56  02F	h	u	0.00	v              	
A2  01D	a	u	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A0  02A	h	d	0.00	LShift         	
A0  02A	i	u	0.00	LShift         	
56  02F	i	d	0.02	v              	
56  02F	i	u	0.00	v              	
A0  02A	i	d	0.00	LShift         	
A2  01D	 	u	0.14	LControl       	
56  02F	h	u	0.00	v              	
56  02F	i	u	0.00	v              	
A0  02A	h	u	0.03	LShift         	
A0  02A	i	u	0.44	LShift         	
74  03F	h	d	14.27	F5             	C:\[...]\EPKL_Executable_v1-4-1\EPKL.exe
74  03F	i	d	0.00	F5 

And below is the key history when I get no effect. Again, it always fills up the default 50 lines.

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
A0  02A	h	d	0.02	LShift         	
A0  02A	i	d	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
56  02F	i	d	0.00	v              	
FF  000	a	u	0.02	not found      	
A2  01D	a	u	0.00	LControl       	
A0  02A	h	u	0.00	LShift         	
A2  01D	a	d	0.00	LControl       	
56  02F	h	d	0.00	v              	
A0  02A	i	u	0.00	LShift         	
56  02F	h	u	0.00	v              	
A2  01D	a	u	0.01	LControl       	
A2  01D	a	d	0.00	LControl       	
56  02F	i	u	0.00	v              	
A0  02A	h	d	0.00	LShift         	
A0  02A	i	d	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
56  02F	i	d	0.00	v              	
FF  000	a	u	0.00	not found      	
A2  01D	a	u	0.00	LControl       	
A0  02A	h	u	0.01	LShift         	
A2  01D	a	d	0.00	LControl       	
56  02F	h	d	0.00	v              	
A0  02A	i	u	0.00	LShift         	
56  02F	h	u	0.00	v              	
A2  01D	a	u	0.00	LControl       	
A2  01D	a	d	0.02	LControl       	
56  02F	i	u	0.00	v              	
A0  02A	h	d	0.00	LShift         	
A0  02A	i	d	0.00	LShift         	
A2  01D	i	d	0.00	LControl       	
56  02F	i	d	0.02	v              	
FF  000	a	u	0.00	not found      	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	u	0.01	LControl       	
56  02F	i	u	0.00	v              	
A0  02A	i	d	0.00	LShift         	
A0  02A	i	u	0.61	LShift         	
74  03F	h	d	13.92	F5             	C:\[...]\EPKL_Executable_v1-4-1\EPKL.exe
74  03F	i	d	0.00	F5

Are you able to share any insight into what's going on here? Is there a way I can continue to use the V key for additional layers without preventing Ctrl + Shift + V from having the desired effect with PowerToys?

Thank you!
TL

@DreymaR
Copy link
Owner

DreymaR commented Feb 29, 2024

"Hook competition" is the reason why PowerToys or other apps with a keyboard hook don't usually work well with EPKL. It is described in the README. Basically, both PowerToys and EPKL make V into a system hotkey, and there's no telling which app gets hold of it first.

@DreymaR DreymaR added answered Guru covered (most of) the issue duplicate Attack Of The Clones labels Feb 29, 2024
@ToastedLion
Copy link
Author

Thanks, DreymaR! It makes sense to me that PowerToys and EPKL might compete for Ctrl + Shift + V. My questions are:

  1. Do you know why I often see "V" as the output? Naively, I would expect to either get the PowerToys behavior if PowerToys gets hold of it first, or EPKL would get hold of it first in which case I would get the active application's implementation of Ctrl + Shift + V, if and only if it exists. It seems odd that Ctrl + Shift + V would ever produce "V".
  2. Is there a way to tell EPKL to "resend" Ctrl + Shift + V so that other applications, including PowerToys, can pick it up? Or is PowerToys implemented at a lower layer to which EPKL can't send anything?
  3. Do you have any other suggestions to get the behavior I want? Or do I have to choose between Ctrl + Shift + V doing what I want vs. having additional layers work for the V key?

Thank you!

@DreymaR
Copy link
Owner

DreymaR commented Mar 6, 2024

As far as I know, you'll have to decide between using PowerToys and EPKL. Even if you could get EPKL to resend certain key combinations to the input stream, there would be no way to get expected EPKL behavior from other keys when PowerToys gets hook priority. I think this gets too complex to contend with.

No, there is no "lower layer" in this context, as far as I know. Both programs use a low-level keyboard hook, and there is no priority queue for such hooks in Windows. A program that intercepts a key event can "pass it on" if so desired, but that is obviously not the default behavior for most programs. Certainly not for EPKL.

One possible way of cirumventing this problem might be if you can set the PowerToys hotkey to some key that EPKL does not hook, such as the F13-24 function keys. You could have EPKL produce one of these, and PowerToys should in theory intercept that. I cannot guarantee that it'd work, but it's possible.

@ToastedLion
Copy link
Author

One possible way of cirumventing this problem might be if you can set the PowerToys hotkey to some key that EPKL does not hook, such as the F13-24 function keys. You could have EPKL produce one of these, and PowerToys should in theory intercept that. I cannot guarantee that it'd work, but it's possible.

This is a great idea, thank you! I will try this out.

Failing that, I'll instead figure out how to map Ctrl + Shift + V directly in EPKL to an AutoHotKey script that manipulates the clipboard to paste as plain text. Given that EPKL is built on AutoHotKey, I'm guessing that this would be relatively straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Guru covered (most of) the issue duplicate Attack Of The Clones
Projects
None yet
Development

No branches or pull requests

2 participants