문제

I looking for a solution where I can "press" two keys at the same time using Java or .NET. Recently I have tried below code in Java which is working perfectly fine on one key. Here is the code for one key

r.keyPress(KeyEvent.VK_R);

Upon execution of this code it press letter 'R'. Now what I'm looking is to press "Windows+R" keys or say a combination of multiple keys not more than two keys at the same time.

도움이 되었습니까?

해결책

ok, from the doc of Robot class, just do:

r.keyPress(KeyEvent.VK_WINDOWS);
r.keyPress(KeyEvent.VK_R);  // VK_WINDOWS key still pressed
r.keyRelease(KeyEvent.VK_R);
r.keyRelease(KeyEvent.VK_WINDOWS);

the keyPress method does not relese the key, so this should work

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top