|

楼主 |
发表于 2024-5-14 16:16:13
|
显示全部楼层
无法运行呢
PS D:\> ./net.ps1
PS D:\> Add-Type -TypeDefinition @"
>> using System;
>> using System.Runtime.InteropServices;
>>
>> public class MouseSimulator
>> {
>> [DllImport("user32.dll")]
>> public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
>>
>> private const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
>> private const uint MOUSEEVENTF_RIGHTUP = 0x0010;
>>
>> public void RightClick(uint x, uint y)
>> {
>> mouse_event(MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0);
>> mouse_event(MOUSEEVENTF_RIGHTUP, x, y, 0, 0);
>> }
>> }
>> "@
Add-Type : 无法添加类型。类型名称“MouseSimulator”已存在。
所在位置 行:1 字符: 1
+ Add-Type -TypeDefinition @"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (MouseSimulator:String) [Add-Type],Exception
+ FullyQualifiedErrorId : TYPE_ALREADY_EXISTS,Microsoft.PowerShell.Commands.AddTypeCommand
PS D:\>
PS D:\> $mouseSimulator = New-Object MouseSimulator
PS D:\> $mouseSimulator.RightClick(x, y)
所在位置 行:1 字符: 28
+ $mouseSimulator.RightClick(x, y)
+ ~
方法调用中缺少“)”。
所在位置 行:1 字符: 28
+ $mouseSimulator.RightClick(x, y)
+ ~
表达式或语句中包含意外的标记“x”。
所在位置 行:1 字符: 29
+ $mouseSimulator.RightClick(x, y)
+ ~
参数列表中缺少参量。
所在位置 行:1 字符: 32
+ $mouseSimulator.RightClick(x, y)
+ ~
表达式或语句中包含意外的标记“)”。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
PS D:\> |
|