Carnac.Logic/KeyMonitor/InterceptKeys.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Diagnostics;
using System.Reactive.Subjects;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Windows.Forms;
namespace Carnac.Logic.KeyMonitor
{
[PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
public class InterceptKeys : IObservable<InterceptKeyEventArgs>, IDisposable
{
static volatile InterceptKeys current;
static readonly object CurrentLock = new object();
readonly Win32Methods.LowLevelKeyboardProc callback;
readonly Subject<InterceptKeyEventArgs> subject;
bool disposed;
IntPtr hookId = IntPtr.Zero;
decimal subscriberCount;
InterceptKeys()
{
subject = new Subject<InterceptKeyEventArgs>();
callback = HookCallback;
}
public static InterceptKeys Current
{
get
{
if (current == null)
{
lock (CurrentLock)
{
if (current == null)
{
current = new InterceptKeys();
}
}
}
return current;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public IDisposable Subscribe(IObserver<InterceptKeyEventArgs> observer)
{
Debug.WriteLine("Subscribed");
IDisposable dispose = subject.Subscribe(observer);
subscriberCount++;
if (subscriberCount == 1)
hookId = SetHook(callback);
return new DelegateDisposable(() =>
{
后面还有 93 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。