![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
DotNet.loadAssembly
"
Microsoft.VisualBasic.dll
"
DotNet.loadAssembly " Microsoft.DirectX.DirectInput.dll "
SystemGuid = DotNetClass " Microsoft.DirectX.DirectInput.SystemGuid "
KeyboardDevice = DotNetObject " Microsoft.DirectX.DirectInput.Device " SystemGuid.Keyboard
CooperativeLevelFlags = DotNetClass " Microsoft.DirectX.DirectInput.CooperativeLevelFlags "
Operators = DotNetClass " Microsoft.VisualBasic.CompilerServices.Operators "
theCooperativeLevelFlags = Operators.OrObject CooperativeLevelFlags.Background CooperativeLevelFlags.NonExclusive
MaxHWND = DotNetObject " System.IntPtr " (Windows.getMAXHWND() as integer)
KeyboardDevice.SetCooperativeLevel MaxHWND theCooperativeLevelFlags
KeyboardDevice.Acquire()
KeyboardState = KeyboardDevice.GetCurrentKeyboardState()
DxKey = DotNetClass " Microsoft.DirectX.DirectInput.Key "
KeyboardState.item dxkey.x
dxkey.a
-- KeyboardDevice.Dispose()
rollout test ""
(
timer clock " testClock " interval: 300 -- tick once a second
label test ""
on clock tick do
(
enableAccelerators = false
KeyboardState = KeyboardDevice.GetCurrentKeyboardState()
test.text = (KeyboardState.item dxkey.a) as string
)
)
createdialog test
DotNet.loadAssembly " Microsoft.DirectX.DirectInput.dll "
SystemGuid = DotNetClass " Microsoft.DirectX.DirectInput.SystemGuid "
KeyboardDevice = DotNetObject " Microsoft.DirectX.DirectInput.Device " SystemGuid.Keyboard
CooperativeLevelFlags = DotNetClass " Microsoft.DirectX.DirectInput.CooperativeLevelFlags "
Operators = DotNetClass " Microsoft.VisualBasic.CompilerServices.Operators "
theCooperativeLevelFlags = Operators.OrObject CooperativeLevelFlags.Background CooperativeLevelFlags.NonExclusive
MaxHWND = DotNetObject " System.IntPtr " (Windows.getMAXHWND() as integer)
KeyboardDevice.SetCooperativeLevel MaxHWND theCooperativeLevelFlags
KeyboardDevice.Acquire()
KeyboardState = KeyboardDevice.GetCurrentKeyboardState()
DxKey = DotNetClass " Microsoft.DirectX.DirectInput.Key "
KeyboardState.item dxkey.x
dxkey.a
-- KeyboardDevice.Dispose()
rollout test ""
(
timer clock " testClock " interval: 300 -- tick once a second
label test ""
on clock tick do
(
enableAccelerators = false
KeyboardState = KeyboardDevice.GetCurrentKeyboardState()
test.text = (KeyboardState.item dxkey.a) as string
)
)
createdialog test
Windows.getMAXHWND()是Max2008新增的函数,故需要Max2008版本,max9可用的过段时间再写,因为这是一个朋友需要的东西,所以,我不急.....