The movement of the maxscript keyboard control box

Source: Internet
Author: User

The tragedy is that it can only be used in a 32-bit version and requires max2008 or a later version. If it needs to be used in another version, it will not be necessary, but it will be troublesome. In addition, this is easier to find an engine.

View code

DOTNET. loadassembly "Microsoft. VisualBasic. dll"
DOTNET. loadassembly "Microsoft. DirectX. directinput. dll"
Global keyboarddevice

Systemguid = dotnetclass "Microsoft. DirectX. directinput. systemguid"
Keyboarddevice = dotnetobject "Microsoft. DirectX. directinput. Device" systemguid. keyboard
Cooperativelevelflags = dotnetclass "Microsoft. DirectX. directinput. cooperativelevelflags"
Thecooperativelevelflags = DOTNET. compareenums cooperativelevelflags. Background cooperativelevelflags. nonexclusive 2
Maxhwnd = dotnetobject "system. intptr" (Windows. getmaxhwnd () as integer)
Keyboarddevice. setcooperativelevel maxhwnd thecooperativelevelflags
Keyboarddevice. Acquire ()

FN timerupdate thesender theevent =
(
Global boxer, keyboarddevice
If not isvalidnode boxer do boxer = Box ()
Movestep = 1
Dxkey = dotnetclass "Microsoft. DirectX. directinput. Key"
Keyboardstate = keyboarddevice. getcurrentkeyboardstate ()

If (keyboardstate. Item dxkey. d) = true do boxer. Pos. x + = movestep
If (keyboardstate. Item dxkey. a) = true do boxer. Pos. X-= movestep
If (keyboardstate. Item dxkey. W) = true do boxer. Pos. Y + = movestep
If (keyboardstate. Item dxkey. S) = true do boxer. Pos. Y-= movestep

)
Dotnettimer = dotnetobject "system. Timers. Timer" 30
DOTNET. addeventhandler dotnettimer "elapsed" timerupdate
Dotnettimer. Start ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.