Warning: file_get_contents(https://whois.pconline.com.cn/jsLabel.jsp?ip=127.0.0.1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884
如何获取当前用户焦点窗口/输入焦点窗口句柄 - huidong

huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


http://cn.voidcc.com/question/p-fhndwizc-ro.html

https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getfocus?redirectedfrom=MSDN

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getforegroundwindow 

https://docs.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-getactivewindow?redirectedfrom=MSDN


根据以上文章,总结出与获取焦点窗口句柄相关的三个函数:

1- GetFocus

2- GetForegroundWindow

3- GetActiveWindow


具体区别:

GetFocus 得到的是在程序窗口中 有焦点的控件 的句柄。【https://baike.baidu.com/item/GetFocus/3823969

GetForegroundWindow 得到的是用户当前使用的窗口的句柄 【https://baike.baidu.com/item/GetForegroundWindow

GetActiveWindow 是得到 该函数可以获得与调用线程消息队列相关的活动窗口的窗口句柄https://baike.baidu.com/item/GetActiveWindow#1


GetActiveWindow 和 GetForegroundWindow的区别:级别不同。前者是线程级的,你的这个线程的活动窗口句柄;后者是系统级的,整个系统目前的活动窗口。参考:https://blog.csdn.net/yazi1297/article/details/36008189 




返回首页


Copyright (C) 2018-2024 huidong