WinKill() source code
WinKill() source code
谁能从AutoIt分享WinKill()
的源代码?
我想知道它是如何工作的消息(是/否/取消),以确保它被正确处理。我想用它来清理桌面从意外弹出窗口
从AutoIt的最新开源版本(以前是开源的)获取的源代码中可以看到,该函数向窗口发送WM_CLOSE消息。如果窗口没有在500ms内关闭,那么它会杀死创建该窗口的进程。
///////////////////////////////////////////////////////////////////////////////
// WinKill()
// Closes a window - uses more force than WinClose
///////////////////////////////////////////////////////////////////////////////
AUT_RESULT AutoIt_Script::F_WinKill(VectorVariant &vParams, Variant &vResult)
{
Win_WindowSearchInit(vParams);
if (Win_WindowSearch() == false)
return AUT_OK; // Required window not found
Util_WinKill(m_WindowSearchHWND);
Util_Sleep(m_nWinWaitDelay); // Briefly pause before continuing
return AUT_OK;
} // WinKill()
///////////////////////////////////////////////////////////////////////////////
// Util_WinKill()
//
// Closes a window with extreme predjudice
//
///////////////////////////////////////////////////////////////////////////////
void Util_WinKill(HWND hWnd)
{
DWORD dwResult;
LRESULT lResult = SendMessageTimeout(hWnd, WM_CLOSE, 0, 0, SMTO_ABORTIFHUNG, 500, &dwResult); // wait 500ms
if( !lResult )
{
// Use more force - Mwuahaha
// Get the ProcessId for this window.
DWORD pid;
GetWindowThreadProcessId( hWnd, &pid );
// Open the process with all access.
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
// Terminate the process.
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
} // Util_WinKill()
这不是一个开源函数。你不可能知道来源。然而,理解起来并不复杂。这是一个简单的函数,有很多If…then…打电话检查标准,然后简单地杀死窗户。与cmd命令非常相似。
AutoIt具有本地和标准功能。原生插件是开源的,你可以在AutoIt安装目录的Include文件夹中找到它们。另一方面,标准的不是开源的。
相关文章:
- "throw expression code" 1e7 >返回 d 是什么?投掷标准::overflow_error( "too big" ) : d;意味 着?
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio Code "undefined reference to `WinMain@16'"
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用VS Code和CMake Tools运行自定义命令
- 修改 VS Code 中的默认C++代码段
- 如何配置Visual Studio Code以使用cygwin,cmake和gcc进行调试
- std::to_string - 'to_string' 不是 'std' 的成员 - Visual Studio Code 1.42.0
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- C++新手,想知道如何使用VS code 2019播放音频文件
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- 如何在Visual Studio Code中重命名我的a.exe文件?
- C++ Visual Studio Code 的设置不起作用
- 以某种方式告诉编译器"Do not process line of code"
- 在VS Code中编译C / C ++时如何禁用自动创建EXE文件?
- remy source code(github) 编译错误在 protobuf 类
- c++ STL cout source code
- 如何重新解释特殊字符的'source code'
- WinKill() source code
- fftshift/ifftshift C/C++ source code