Python Sample Programs |
Site Top > Python Sample Programs > Python Sample Programs >
Scroll Lock key detection
4/13/2024
→ Switch to C# → Switch to Visual Basic
Scroll Lock key detection
import ctypes
windowsAPI = ctypes.WinDLL('User32.dll')
if (windowsAPI.GetKeyState(145) & 0x8001 != 0):
print('Scroll Lock')
else:
print('No Scroll Lock')
Note: This program will only work on Windows.
Note: The basis for 0x8001 is the implementation of System.Windows.Forms.Control.IsKeyLocked. I don't understand the meaning of the high order bits.