我正在使用全局键盘和鼠标钩来处理键盘和鼠标活动.我遇到的问题就像用户使用团队查看器或远程桌面(连接到远程计算机),然后我们无法获得键盘和鼠标挂钩(挂钩在本地计算机上).我们有一个后台计时器运行,它继续检查何时是最后输入时间然后如果它大于1分钟我将卸载挂钩并安装它.当我们这样做时,我每次卸载并安装钩子时都会获得唯一指针(ptrHook),但我无法收听事件.一旦挂钩丢失,即使在卸载和安装挂钩后无法获取事件.
对于鼠标钩
public void InstallHook(int processId)
{
try
{
ProcessModule objCurrentModule = null;
objCurrentModule = Process.GetProcessById(processId).MainModule;
objMouseProcess = new LowLevelMouseProc(captureMouse);
//In order to avoid memory access violation error allocate the memory from GCHandle
//Refer :http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/b0defb8f-1242-4485-a680-8773da07db2f
GCHandle.Alloc(objMouseProcess);
ptrHook = SetWindowsHookEx(WH_MOUSE_LL, objMouseProcess, GetModuleHandle(objCurrentModule.ModuleName), 0);
}
}
Run Code Online (Sandbox Code Playgroud)
对于键盘钩
public void InstallHook(int processId)
{
try
{
ProcessModule objCurrentModule = null;
objCurrentModule = Process.GetProcessById(processId).MainModule;
objKeyboardProcess = new LowLevelKeyboardProc(captureKey);
//In order to avoid memory access violation error allocate the memory from GCHandle
//Refer :http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/b0defb8f-1242-4485-a680-8773da07db2f
GCHandle.Alloc(objKeyboardProcess);
ptrHook …
Run Code Online (Sandbox Code Playgroud) 我使用UISpy来检测outlook TO Address Field但是uispy将值返回为"?"
如果它是普通文本,那么Uispy会正确检测到它显示的是To Address.问题是当我们在To address字段中输入任何电子邮件地址时,它转换为超链接我们如何使用Ui间谍获取地址.
我正在使用Accord.Video.FFMPEG来录制屏幕.我面临的问题是CPU和内存利用率都过高.通常,我们的进程使用最大2%的CPU和30 MB的内存,但是当我们开始视频捕获时,CPU上升到17%,内存达到700MB.我试着把
所以GC.Collect();
但没有用.
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
try
{
if (this._isRecording)
{
int screenRecordingLength = screenRecrodingRule != null ? screenRecrodingRule.length : 500;
//Bitmap frame;
Bitmap frame = eventArgs.Frame;
{
Graphics graphics = Graphics.FromImage(frame);
try
{
CURSORINFO pci;
pci.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CURSORINFO));
if (GetCursorInfo(out pci))
{
if (pci.flags == CURSOR_SHOWING)
{
int x = pci.ptScreenPos.x - screenLeft;
int y = pci.ptScreenPos.y - screenTop;
Color c = Color.Yellow;
float width = 2;
int radius = 30;
if ((Control.MouseButtons & …
Run Code Online (Sandbox Code Playgroud) 我正在使用IMessageFilter
鼠标和键盘来跟踪用户输入.
static void Main()
{
try
{
AddKeyboardMouseDevice(this.Handle);
RegisterDevices();
}
catch (Exception ex)
{
Console.WriteLine("Unhandled exception occurred tray application." + ex.Message);
}
}
public void AddKeyboardMouseDevice(IntPtr windowHandle)
{
devices.Add(new RAWINPUTDEVICE(1, 6, 0x100, windowHandle));
devices.Add(new RAWINPUTDEVICE(1, 2, 0x100, windowHandle));
}
public bool RegisterDevices()
{
if (devices.Count == 0) return false;
log.DebugFormat("Registering for keyboard mouse hook");
RAWINPUTDEVICE[] d = devices.ToArray();
bool result = RegisterRawInputDevices(d, devices.Count, Marshal.SizeOf(typeof(RAWINPUTDEVICE)));
return result;
}
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_INPUT)
{ …
Run Code Online (Sandbox Code Playgroud) 我试图从 Windows 服务挂钩到 Outlook 应用程序,但出现异常操作不可用(来自 HRESULT 的异常:0x800401E3(MK_E_UNAVAILABLE))这是我的代码。
public void ItemSendEvent()
{
try
{
if (Process.GetProcessesByName(ApplicationConstants.OUTLOOK_PROCESS_NAME).Count() > 0)
{
// If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
outlookApplication = Marshal.GetActiveObject(ApplicationConstants.OUTLOOK_APPLICATION_NAME) as Microsoft.Office.Interop.Outlook.Application;
Microsoft.Office.Interop.Outlook.NameSpace nameSpace = outlookApplication.GetNamespace(ApplicationConstants.OUTLOOK_NAME_SPACE);
nameSpace.Logon("", "", Missing.Value, Missing.Value);
nameSpace = null;
outlookApplication.ItemSend += outlookApplication_ItemSend;
}
log.Info("Outlook Item Send event registered successfully.");
}
catch (System.Exception ex)
{
log.Error("Exception occurred while registering Outlook Item Send event. " + ex.Message);
}
} …
Run Code Online (Sandbox Code Playgroud) 我正在使用chart.js来显示折线图.如何隐藏chart.js折线图的工具提示标签?工具提示中的标签显示,undefined
所以我想隐藏标签(请参见屏幕截图)?
也许有一种方法可以修改工具提示,我只能在工具提示中显示图例值?我的代码如下:
myLine = new Chart(ctx).Line(lineChartData, {
type: 'line',
responsive: true,
scaleShowGridLines : false,
bezierCurve : false,
animationEasing: "linear",
tooltipEvents: ["mousemove", "touchstart", "touchmove"],
showTooltips: true,
scaleLineColor: "rgba(0,0,0,.8)",
});
Run Code Online (Sandbox Code Playgroud)
我正在使用 table2excel 将由 jQuery DataTables 支持的数据表导出到 Excel。我可以将数据导出到 Excel,但无法导出带有标题的表格。
这是我的代码
$('#btn-export').on('click', function () {
$('<table>').append(table.$('tr').clone()).table2excel({
exclude: "",
name: "EmailTracking",
filename: "EmailTracking" //do not include extension
});
});
Run Code Online (Sandbox Code Playgroud)
这是我的 HTML:
<table id="userGrid" class="table table-striped table-bordered dt-responsive nowrap " cellspacing="0" width="100%">
<thead>
<tr>
<th>User</th>
<th>Subject</th>
<th>Sent On</th>
<th>To</th>
<th>Cc</th>
<th>Bcc</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud) .net ×5
c# ×4
accord.net ×1
aforge ×1
chart.js ×1
datatables ×1
excel ×1
html ×1
inspect ×1
javascript ×1
jquery ×1
linechart ×1
mouseevent ×1
ms-office ×1
outlook ×1
raw-input ×1
ui-spy ×1