By Timothy J. Green | Created on 2025-08-02 20:31:08
&H8000 is a hexadecimal value that represents the most significant bit (MSB) in a 16-bit integer. In binary, it is represented as 1000000000000000
. When this bit is set to 1, it indicates that the corresponding key or button is pressed down.
Example: Checking if the Shift Key is Pressed
The code snippet you provided demonstrates how to check if the Shift key is pressed:
Public Const VK_SHIFT = &H10
Dim IsShifted As Boolean
IsShifted = (GetKeyState(VK_SHIFT) And &H8000) <> 0
This code uses bitwise AND to check if the most significant bit is set in the return value of GetKeyState
. If it is, then the Shift key is pressed.
Example: Checking if the Alt Key is Pressed
You can use a similar approach to check if the Alt key is pressed:
Public Const VK_ALT = &H12
Dim IsALT As Boolean
IsALT = (GetKeyState(VK_ALT) And &H8000) <> 0
Example: Copying Text to Clipboard with Alt and X
You can use the following code to copy text to the clipboard when the user presses Alt and X:
Public Const VK_ALT = &H12
Public Const VK_X = &H58
If (GetKeyState(VK_ALT) And &H8000) <> 0 Then
If GetAsyncKeyState(VK_X) < 0 Then
Clipboard.SetText "Your text here"
End If
End If
Conclusion
&H8000 is a hexadecimal value that represents the most significant bit in a 16-bit integer. It can be used to check if a key or button is pressed down by using bitwise AND with the return value of GetKeyState
.
Last updated on Jun 21, 2005Sources:- [
What are &H1, &H8000, etc.? | Tek-Tips] (
https://www.tek-tips.com/threads/what-are-h1-h8000-etc.1080522/)
- [
stop h1 tag going onto next line | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/stop-h1-tag-going-onto-next-line.876965/)
- [
Microsoft VBScript runtime error '800a01b6' | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/microsoft-vbscript-runtime-error-800a01b6.419805/)
- [
Launch .VBS file from button on HTML page | Tek-Tips] (
https://www.tek-tips.com/threads/launch-vbs-file-from-button-on-html-page.931380/)
- [
Need Help Checking VBScript Value for Not Null | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/need-help-checking-vbscript-value-for-not-null.802626/)
- [
Moving Aplications to a new screen in C# | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/moving-aplications-to-a-new-screen-in-c.1416749/)
- [
HTA new window with Parameters | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/hta-new-window-with-parameters.1295803/)
- [
JOIN from HOLD Files possible? | Tek-Tips] (
https://www.tek-tips.com/threads/join-from-hold-files-possible.490981/)
- [
VBA NotifyIcon | Tek-Tips] (
https://www.tek-tips.com/index.php?threads/vba-notifyicon.1521979/)
- [
VBscript and Javascript in the same HTA Application not working...] (
https://www.tek-tips.com/index.php?threads/vbscript-and-javascript-in-the-same-hta-application-not-working.1437650/)