-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
466 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
citrix-common/src/main/java/com/blazemeter/jmeter/citrix/client/Win32Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.blazemeter.jmeter.citrix.client; | ||
|
||
import static com.sun.jna.platform.win32.WinUser.MAPVK_VK_TO_VSC; | ||
|
||
import com.sun.jna.platform.win32.User32; | ||
import com.sun.jna.platform.win32.WinDef; | ||
import java.awt.event.KeyEvent; | ||
|
||
public class Win32Utils { | ||
|
||
public static int getVirtualKey(int keyCode) { | ||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-vkkeyscanexw | ||
WinDef.HKL keyLayoutID = User32.INSTANCE.GetKeyboardLayout(0); | ||
return User32.INSTANCE.VkKeyScanExW((char) keyCode, keyLayoutID); | ||
} | ||
|
||
public static char getVKCharacter(int vkCode, boolean vkShift, boolean vkAlt, boolean vkCtrl) { | ||
|
||
//https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeyboardlayout | ||
int currentThread = 0; | ||
WinDef.HKL keyLayoutID = User32.INSTANCE.GetKeyboardLayout(currentThread); | ||
|
||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mapvirtualkeyexa | ||
int scanCode = User32.INSTANCE.MapVirtualKeyEx(vkCode, MAPVK_VK_TO_VSC, keyLayoutID); | ||
|
||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-tounicodeex | ||
byte[] keyStates = new byte[256]; | ||
byte keyDownState = (byte) 128; | ||
keyStates[KeyEvent.VK_SHIFT] = vkShift ? keyDownState : 0; | ||
keyStates[KeyEvent.VK_ALT] = vkAlt ? keyDownState : 0; | ||
keyStates[KeyEvent.VK_CONTROL] = vkCtrl ? keyDownState : 0; | ||
|
||
char[] buff = new char[1]; | ||
int buffCharSize = 1; | ||
int menuActiveFlag = 0; | ||
int ret = User32.INSTANCE.ToUnicodeEx( | ||
vkCode, scanCode, keyStates, buff, buffCharSize, menuActiveFlag, keyLayoutID | ||
); | ||
|
||
switch (ret) { | ||
case -1: //Error | ||
return (char) -1; | ||
|
||
case 0: //No Translation | ||
return (char) 0; | ||
|
||
default: //Returning key... | ||
return buff[0]; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.