c# - 我的 KeyStrokesCounter 一直运行良好,直到今天
问题描述
我正在开发一个开发秒表,它有一个用于击键计数器的可执行文件和一个用于主软件的可执行文件,我的 Key counter 可执行文件既不能在我的主软件项目中工作,也不能在独立的 Key counter 项目中工作。
昨天一切正常,但现在不行,我真的不知道原因。
不可能是因为最近的 Windows 更新,对吧?
我已经清理了项目,进行了扫描,试图从代码中注释掉不必要的部分,当我删除我的逻辑时,他似乎可以检测到我的密钥,但没有它就无法正常工作,就像我说的昨天一切正常。
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;
using SlipegFramework;
namespace KeyStrokeCounter
{
class Program
{
[DllImport("user32.dll")]
public static extern int GetAsyncKeyState(Int32 i);
private static int Count = 0;
static void Main(string[] args)
{
//if (args[0] == "true")
//{
while (true)
{
Thread.Sleep(1);
for (int i = 0; i < 255; i++)
{
int KeyState = GetAsyncKeyState(i);
if (KeyState == 1 || KeyState == -32767) //Doesn't detect anything
{
Count++;
Console.WriteLine(KeyState);//So don't print anything for debug.
Console.WriteLine(Count);
SlipegFramework.IO.WriteToBinary(Environment.CurrentDirectory, "Strks.bin", Count); //You can ask for this code but it shoudn't be necessary
}
}
}
//}
}
}
}
只应该增加我的 Count 变量并使用位于我的个人工具中的 BinaryWriter 将其打印到 bin 文件中。
我不是英语,如果有什么不清楚的地方很抱歉。感谢您给出的任何答案。
EDIT1:我已经更新了 Windows,我目前正在更新 Visual Studio,即使我不相信他与它有关,并进行系统扫描。这太奇怪了,也许是我的系统,某种内存损坏?
或者 user32.dll 有什么问题?我在一个新项目上尝试了这段代码,它没有改变任何东西。
EDIT2:做了一些挖掘并有了一个想法,我将我的软件打开到一个虚拟机中,它工作正常,但只在虚拟机中,所以它是我的系统。我该如何解决?
有人有想法吗?明天系统重启后我会尝试更多。
解决方案
所以问题解决了,这是由最近的 Windows 10 更新引起的,回滚到以前的修复它。
推荐阅读
- angular - 在土星材料日期范围选择器中显示日期值
- sql - SELECT * FROM 之间的差异
- python - “运行时未实现的依赖关系”:创建动态依赖关系时出错
- javascript - 如何发送 VueJS 对象以存储在 Laravel 控制器中?
- reactjs - Logout error with conditional collection on React Firebase app
- python - 更新变量并更改导入模块
- python - 无法使用scrapy提取数据
- python-3.x - 如何编写具有多种数据类型python的矩阵?
- reactjs - 运行生产构建时找不到页面在重新加载时反应 js
- c# - 序列化为没有属性名的 json