zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    多态
    封装,继承,多态
    基本类型和引用类型的区别
    第七天 面向对象
    什么是Java线程池
    游戏内核架构
    放松
    静不下来心写代码
    速度和正确率
    理顺思路
  • 原文地址:https://www.cnblogs.com/sitt/p/3026778.html
Copyright © 2011-2022 走看看