QQ聊天

MaxScript用.net调winapi来设置鼠标位置

 

也是有网友需要写的范例

 

Fn GetFunctionSetCursorPos = 
(
    local result = undefined
    if DotNetClass "WinAPI.Utilities" == undefined then
    (
        CSharpCodeSource ="using System;
        using System.Runtime.InteropServices;
        namespace WinAPI
        {
            public class Utilities
            {
                [DllImport(\"user32.dll\", EntryPoint = \"SetCursorPos\")] 
                public static extern int SetCursorPos(int x, int y); 
            }
        }
        "
        CSharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
        CompilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

        CompilerParams.ReferencedAssemblies.Add("System.dll")
        CompilerParams.GenerateExecutable = false
        CompilerParams.GenerateInMemory = true

        CompilerResults = CSharpProvider.CompileAssemblyFromSource CompilerParams #(CSharpCodeSource)

        WinAssembly = CompilerResults.CompiledAssembly
        tempObject = WinAssembly.CreateInstance "WinAPI.Utilities"
        result = tempObject.SetCursorPos
    )
    else
    (
        result = (DotNetClass "WinAPI.Utilities").SetCursorPos
    )
    result 
)

SetCursorPos = GetFunctionSetCursorPos()
SetCursorPos 0 0

 

 

 

posted @ 2013-04-17 18:06  SITT  阅读(774)  评论(0编辑  收藏  举报
QQ聊天