zVirtualDesktop icon indicating copy to clipboard operation
zVirtualDesktop copied to clipboard

Cancel out original keypress in Send Keypress

Open eyahlin opened this issue 6 years ago • 19 comments

Thanks for sharing this. So my issue is this: when I try to map a key combination, like, say Alt- to another keystroke like Shift-Win-<Left>, the Alt and tilde are still engaged when the Shift-Win-<Left> keystroke is sent. What we need is for the Alt- to not be sent, and only the Shift-Win-<Left> to be sent. Therefore the original keypress must be canceled out by the new keypress sequence it is meant to replace.

eyahlin avatar Aug 21 '19 09:08 eyahlin

Thanks for sharing the feedback. I will test this out. It should not be happening, obviously, but technically, I'm not sending the Alt- down the hook chain so another app shouldn't see them as pressed. It should work this way and I haven't seen any issue. However, certain key combinations may not act the same so I will test with what you are doing.

mzomparelli avatar Aug 21 '19 12:08 mzomparelli

Am I missing the choice to use the dash/underscore key. Looks that way. Not sure how that would have slipped by.

mzomparelli avatar Aug 21 '19 22:08 mzomparelli

In an effort to replicate your issue can you give me more detail to how you are using these hotkeys? What application is handling the keystroke you are having zVD send (SHIFT+WIN+~)?

mzomparelli avatar Aug 22 '19 00:08 mzomparelli

If trying to have zVD handle the one it just sent then, yeah, looking at the code, the previous keys are still down, however, that is an easy fix which I just added the the single line of code that should allow that to work. I'm not sure why you would do that if that's what you're trying to do. Please give me more insight to this if possible.

mzomparelli avatar Aug 22 '19 00:08 mzomparelli

So here's basically what I'm trying to do. The Windows shortcut for moving a window to another screen (monitor) is Shift-Win-#. I want the Alt-Shift-` keystroke to also do that. If I use the Send keypress function, it doesn't really send Shift-Win-#, but Alt-Shift-Win-#, which really doesn't do anything. That is why the original Alt and Shift keys must be depressed when the Shift and Win keys are sent. That way, the original keystrokes are replaced by the new ones.

eyahlin avatar Aug 22 '19 02:08 eyahlin

ugh what did you just have me do! I pressed SHIFT+WIN+3 thinking it would move the window to my third monitor and Chrome opened a new page and my PC went grayscale. The really messed up part is that is wasn't grayscale due to the Color Filter setting. I had to restart my PC to get color back.

I had my son try on his PC and while his didn't go grayscale, it also didn't move the window.

I am aware of SHIFT+WIN+LEFT or RIGHT, but never knew about the numbers. Either way, those don't appear to be defaults in my Windows environment.

Are you sure this is a Windows default hotkey?

mzomparelli avatar Aug 22 '19 02:08 mzomparelli

Oh dang! So sorry about that typo! It was supposed to be the Left or Right arrow key instead of #. I'm using a dual monitor set-up so either will work because the window movement just wraps around. Apologies again!

eyahlin avatar Aug 22 '19 02:08 eyahlin

I needed to restart anyway. I probably should have checked for updates first lol

ok, now that I understand what you're doing, let me try it out and see if I can fix it.

mzomparelli avatar Aug 22 '19 02:08 mzomparelli

Wouldn't it make more sense for me to implement this as new hotkey action where you could even choose the monitor?

mzomparelli avatar Aug 22 '19 02:08 mzomparelli

ok, so one way to get around this right now is to use CapsLock as a modifier and use CapsLock+Tilde as your hotkey to send. I'll have to think about how to handle this. Probably go with the hotkey action.

mzomparelli avatar Aug 22 '19 03:08 mzomparelli

I might have to remove the Send Keystroke action. After further testing, it might only work with the CapsLock modifier.

mzomparelli avatar Aug 22 '19 03:08 mzomparelli

Yes, I'm implementing a workaround for now. But I would largely prefer the original shortcut and intended behavior since the shortcut is already in my left hand's muscle memory. 😁 Of course, a more robust way would be for you to create a new action to move a window to another monitor (instead of simulating a hotkey which does it), if it wouldn't be too much trouble.

eyahlin avatar Aug 22 '19 04:08 eyahlin

Good job! Your issue resulted in 3 tasks.

mzomparelli avatar Aug 27 '19 00:08 mzomparelli

Thanks, Michael. I'll stay posted for updates. :)

eyahlin avatar Aug 28 '19 15:08 eyahlin

I made a change in 1.0.93.6 that should allow the Send Keystroke to work better. Basically I just added a delay of 1 second before the keystroke is sent. This gives you one second to let go of the current keys. We can play around with this delay if it is too much or not enough. Let me know if this helps your issue.

mzomparelli avatar Oct 26 '19 03:10 mzomparelli

Thank you! I tried it, and it works. However, the way I'm using the keystroke (move windows around) would require that my fingers are still pressing on the current keys, because I could possibly press the keystrokes more than once per second. This would mean that I would need to release the keys and wait for a second before I could fire another shortcut. Is it possible to send the keystroke replacement regardless of what is currently pressed instead?

eyahlin avatar Nov 07 '19 15:11 eyahlin