HavenDV / H.InputSimulator

Allows you to simulate global mouse and keyboard events.
https://github.com/TChatzigiannakis/InputSimulatorPlus
Microsoft Public License
75 stars 14 forks source link

Some simulated input commands were not sent successfully #3

Closed mofashaonvyiliya closed 2 years ago

mofashaonvyiliya commented 2 years ago

Describe the bug

System. InvalidOperationException: Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.

Steps to reproduce the bug

C:\Users\Administrator\source\repos\CopyPaste\CopyPaste\bin\Debug Copy other path Open other path Show error log

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Platform

Windows Forms

IDE

Visual Studio 2019

Additional context

No response

mofashaonvyiliya commented 2 years ago

有关调用实时(JIT)调试而不是此对话框的详细信息, 请参见此消息的结尾。

** 异常文本 ** System.InvalidOperationException: Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information. 在 WindowsInput.WindowsInputMessageDispatcher.DispatchInput(INPUT[] inputs) 在 WindowsInput.KeyboardSimulator.ModifiedKeyStroke(IEnumerable1 modifierKeyCodes, IEnumerable1 keyCodes) 在 WindowsInput.KeyboardSimulator.ModifiedKeyStroke(VirtualKeyCode modifierKeyCode, VirtualKeyCode keyCode) 在 CopyPaste.Form1.timer1_Tick(Object sender, EventArgs e) 位置 C:\Users\Administrator\source\repos\CopyPaste\CopyPaste\Form1.cs:行号 33 在 System.Windows.Forms.Timer.OnTick(EventArgs e) 在 System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

** 已加载的程序集 ** mscorlib 程序集版本:4.0.0.0 Win32 版本:4.8.4110.0 built by: NET48REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

CopyPaste 程序集版本:1.0.0.0 Win32 版本:1.0.0.0 基本代码:file:///C:/Users/Administrator/Desktop/CopyPaste/CopyPaste/bin/Debug/CopyPaste.exe

System.Windows.Forms 程序集版本:4.0.0.0 Win32 版本:4.8.4110.0 built by: NET48REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System 程序集版本:4.0.0.0 Win32 版本:4.8.4110.0 built by: NET48REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Drawing 程序集版本:4.0.0.0 Win32 版本:4.8.3761.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

H.InputSimulator 程序集版本:1.2.6.0 Win32 版本:1.2.6.0 基本代码:file:///C:/Users/Administrator/Desktop/CopyPaste/CopyPaste/bin/Debug/H.InputSimulator.DLL

System.Configuration 程序集版本:4.0.0.0 Win32 版本:4.8.3761.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Core 程序集版本:4.0.0.0 Win32 版本:4.8.4110.0 built by: NET48REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Xml 程序集版本:4.0.0.0 Win32 版本:4.8.3761.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

System.Windows.Forms.resources 程序集版本:4.0.0.0 Win32 版本:4.8.3761.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll

mscorlib.resources 程序集版本:4.0.0.0 Win32 版本:4.8.3761.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll

** JIT 调试 ** 要启用实时(JIT)调试, 该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置 jitDebugging 值。 编译应用程序时还必须启用 调试。

例如:

启用 JIT 调试后,任何未经处理的异常 都将被发送到在此计算机上注册的 JIT 调试程序, 而不是由此对话框处理。

HavenDV commented 2 years ago

Hello. Thank you for message. Please think of the library as a high-level wrapper over Win32 calls. In this case, over the call to SendInput. Unfortunately, this is a limitation of the API itself, according to this documentation: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput#remarks https://en.wikipedia.org/wiki/User_Interface_Privilege_Isolation

The easiest way to get around this is to run your application as an administrator.

ZGGSONG commented 4 months ago

Hello, I used the project's latest Nuget package, and remind the user to use administrator privileges to open the program, but still reported this error what is the reason ah, the following is the log content

2024-07-04 14:53:50.871 [INF] STranslate_1.1.5.703[Administrator] Opened...
2024-07-04 14:54:04.881 [WRN] Replace Execute Error: Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.
2024-07-04 14:54:04.882 [ERR] UI线程异常
System.InvalidOperationException: Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.
   at WindowsInput.WindowsInputMessageDispatcher.DispatchInput(INPUT[] inputs) in /_/src/libs/H.InputSimulator/WindowsInputMessageDispatcher.cs:line 37
   at WindowsInput.KeyboardSimulator.TextEntry(String text) in /_/src/libs/H.InputSimulator/KeyboardSimulator.cs:line 307
   at STranslate.Helper.InputSimulatorHelper.PrintText(String content)
   at STranslate.ViewModels.Preference.ReplaceViewModel.FailAsync(CancellationToken cancellationToken)
   at STranslate.ViewModels.Preference.ReplaceViewModel.ExecuteAsync(String content, CancellationToken token)
   at STranslate.ViewModels.NotifyIconViewModel.ReplaceTranslateAsync(Window view)
   at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
ZGGSONG commented 4 months ago

I found that 360 security software was installed on the user's computer, and the analog keyboard input was intercepted by 360.

image