我的应用程序使用鼠标单击鼠标点击控制台窗口外的屏幕区域win32api.mouse_event.这会导致我的窗口失去焦点,因此无法检测按键msvcrt.kbhit.
我的问题是,如何在控制台窗口不可见/活动的情况下实现这样的功能?
编辑:
这是示例代码.这只是一个基本的控制台版本.如果控制台消失,请将其设置为保持在顶部.一旦它在控制台外部(100,100)发出咔嗒声,按Esc键不会突破循环.如何为这样的问题实现休息?
import msvcrt, win32api, win32con
pixelx = 100
pixely = 100
win32api.SetCursorPos((pixelx,pixely))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,pixelx,pixely,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,pixelx,pixely,0,0)
while 1:
print 'Testing..'
# body of the loop ...
if msvcrt.kbhit():
if ord(msvcrt.getch()) == 27:
break
Run Code Online (Sandbox Code Playgroud) 我使用 .inf 文件手动安装我的驱动程序。到现在为止,我从 inf 文件夹中删除了 oem.inf 和 .pnf 文件以进行卸载。每当我安装新驱动程序时,我都会删除/卸载旧的 inf 和 pnf 文件。
在我的旧卸载(通过删除 .inf 和 .pnf 文件)中,我没有修改或删除任何注册表设置。
在这种情况下,我是否要更改或删除注册表中的任何设置(例如:devnode)?
我有一个应用程序的两个代码库.我需要将所有目录中的所有文件从较新的代码库复制到较旧的代码库中的.java(因此我可以将其提交给svn).
如何编写批处理文件来执行此操作?
我正在尝试使用devcon.exe来检查各种硬件的状态.在示例中,我正在尝试检查我的SATA HBA状态,但是devcon正在抱怨它.这是代码:
int main(int argc, char** argv) {
std::string cmdLine("\"C:\\Users\\afalanga\\Documents\\Visual Studio 2010\\Projects\\PlayGround\\Debug\\devcon.exe\" status PCI\\VEN_8086^&DEV_3A22^&SUBSYS_75201462^&REV_00");
char* pCmdLine(new char[cmdLine.length() + 10]);
memset(pCmdLine, 0, cmdLine.length() + 10);
for(int i(0); i < cmdLine.length(); i++)
pCmdLine[i] = cmdLine.at(i);
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi = {0};
if(!CreateProcess(NULL, pCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
std::cout << "Create child process failed. Error code: "
<< GetLastError() << std::endl;
return 1;
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
问题是,当上面执行时,devcon抱怨说"找不到匹配的设备".但是,如果我将该命令行从调试器复制/粘贴到我的命令提示符并按Enter键(或者当然删除调试器围绕它的所有包含引号),该命令将按预期完美地执行.
我在处理字符串时遇到了什么问题?以上是在MSDN上读取CreateProcess()文档的结果(发现不一定需要第一个参数,而cmd args根本不应该去那里).我分配10个额外字节的内存来复制字符串的原因是,在CreateProcess()函数的内部可能会改变"无论什么",而不会踩到其他内存.至少,当我这样做时,这是我的想法.
我正在尝试执行此操作,但它不起作用,这是我的错误:
必须使用'。'或'-> '调用'((test *)this)-> test :: mapping.std :: map <_Key,_Tp,_Compare,_Alloc> :: operator []中的指针成员函数(test :: *)(int),std :: less>,std :: allocator,void(test :: *)(int)>>>((((const key_type)(&str))))(... )”,例如“(...-> *((test *)this)-> test :: mapping.std :: map <_Key,_Tp,_Compare,_Alloc> :: operator [],void(test :: *)(int),std :: less>,std :: allocator,void(test :: *)(int)>>>((((const key_type)(&str))))(...)'
test.h:
#include....
using namespace std;
class test
{
public:
std::map<std::string, void(test::*)(int)> mapping;
void Add(int);
};
test.cpp:
test::test()
{
mapping["Add"]=&test::Add;
string str = "Add";
this.*mapping[str](3);// dosnt work!!!!
}
void …Run Code Online (Sandbox Code Playgroud)