首页 新闻 会员 周边 捐助

调用windows api中sendMessage 发送WM_CLOSE 程序关不掉

0
悬赏园豆:100 [已解决问题] 解决于 2016-08-17 17:20

  我通过FindWindow找到窗口的句柄,然后向这个窗口发送消息

win32api.SendMessage(hwnd,win32con.WM_CLOSE,0,0),用Python写的,问题是有的窗口能关掉,有的关不掉, 比如QQ就能关掉,但是百度杀毒关不掉,为什么呀?

niechangxu的主页 niechangxu | 初学一级 | 园豆:69
提问于:2015-05-24 17:45
< >
分享
最佳答案
0

直接用CloseWindow这个API看看能不能关掉呢

收获园豆:34
I,Robot | 大侠五级 |园豆:9783 | 2015-05-24 20:32

CloseWindow是让窗口最小化,不是关掉。。百度杀毒也没有最小化的那个按钮啊。。。

niechangxu | 园豆:69 (初学一级) | 2015-05-24 22:11

@niechangxu: 直接进程Kill吧。

 

PS:有些软件点击右上角X默认是最小化的。。。。。。

XiaoFaye | 园豆:3087 (老鸟四级) | 2015-05-25 04:26

@XiaoFaye: 已测试,CLoseWindows不好使。。代码是这个样子的

def enumFunc1(hwnd,extra):
    text = win32gui.GetWindowText(hwnd)
    name = win32gui.GetClassName(hwnd)
    print text ,"##",name
    if text == "百度杀毒" :
        win32gui.CloseWindow(hwnd)


win32gui.EnumWindows(enumFunc1,None)
niechangxu | 园豆:69 (初学一级) | 2015-05-25 09:29
其他回答(2)
0

额,有意思。百度杀毒卸载都很困难,跟别说你关它了。百度特恶心。

收获园豆:33
[0] | 园豆:1257 (小虾三级) | 2015-05-24 19:54

这个不是重点。。。现在我想知道怎么能通过发消息做到 和鼠标点击右上角x 一样的功能。。。

支持(0) 反对(0) niechangxu | 园豆:69 (初学一级) | 2015-05-24 19:57
0

用spy++ 捕获下百毒杀软的消息看看。  不要想流氓杀软能这么容易让人关闭

收获园豆:33
问天何必 | 园豆:3311 (老鸟四级) | 2015-05-25 09:26

是找出来了,但是不知道他用什么函数发送的消息呀

<00770> 000106A8 R WM_NCHITTEST nHittest:HTCLIENT
<00771> 000106A8 S WM_NCHITTEST xPos:1093 yPos:311
<00772> 000106A8 R WM_NCHITTEST nHittest:HTCLIENT
<00773> 000106A8 S WM_MOUSEACTIVATE hwndTopLevel:000106A8 nHittest:HTCLIENT uMsg:WM_LBUTTONDOWN
<00774> 000106A8 R WM_MOUSEACTIVATE fuActivate:MA_ACTIVATE
<00775> 000106A8 S WM_WINDOWPOSCHANGING lpwp:0018F514
<00776> 000106A8 R WM_WINDOWPOSCHANGING
<00777> 000106A8 S WM_WINDOWPOSCHANGED lpwp:0018F514
<00778> 000106A8 R WM_WINDOWPOSCHANGED
<00779> 000106A8 S WM_ACTIVATEAPP fActive:True dwThreadID:00000000
<00780> 000106A8 R WM_ACTIVATEAPP
<00781> 000106A8 S WM_NCACTIVATE fActive:True
<00782> 000106A8 R WM_NCACTIVATE
<00783> 000106A8 S WM_ACTIVATE fActive:WA_CLICKACTIVE fMinimized:False hwndPrevious:(null)
<00784> 000106A8 S WM_IME_SETCONTEXT fSet:1 iShow:C000000F
<00785> 000106A8 S WM_IME_NOTIFY dwCommand:IMN_OPENSTATUSWINDOW dwCommand:00000002 dwData:00000000
<00786> 000106A8 R WM_IME_NOTIFY
<00787> 000106A8 R WM_IME_SETCONTEXT
<00788> 000106A8 S WM_SETFOCUS hwndLoseFocus:(null)
<00789> 000106A8 R WM_SETFOCUS
<00790> 000106A8 R WM_ACTIVATE
<00791> 000106A8 S WM_SETCURSOR hwnd:000106A8 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN
<00792> 000106A8 R WM_SETCURSOR fHaltProcessing:False
<00793> 000106A8 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:293 yPos:26
<00794> 000106A8 S WM_NOTIFY idCtrl:67240 pnmh:0018EFEC
<00795> 000106A8 R WM_NOTIFY
<00796> 000106A8 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:293 yPos:26
<00797> 000106A8 P WM_PAINT hdc:00000000
<00798> 000106A8 P WM_LBUTTONUP fwKeys:0000 xPos:293 yPos:26
<00799> 000106A8 S WM_CAPTURECHANGED hwndNewCapture:00000000
<00800> 000106A8 R WM_CAPTURECHANGED
<00801> 000106A8 S message:0x0090 [未知] wParam:00000000 lParam:00000000
<00802> 000106A8 R message:0x0090 [未知] lResult:00000000
<00803> 000106A8 S WM_WINDOWPOSCHANGING lpwp:0018EF48
<00804> 000106A8 R WM_WINDOWPOSCHANGING
<00805> 000106A8 S WM_WINDOWPOSCHANGED lpwp:0018EF48
<00806> 000106A8 R WM_WINDOWPOSCHANGED
<00807> 000106A8 S WM_NCACTIVATE fActive:False
<00808> 000106A8 R WM_NCACTIVATE fDeactivateOK:True
<00809> 000106A8 S WM_ACTIVATE fActive:WA_INACTIVE fMinimized:False hwndPrevious:(null)
<00810> 000106A8 R WM_ACTIVATE
<00811> 000106A8 S WM_ACTIVATEAPP fActive:False dwThreadID:00001A80
<00812> 000106A8 R WM_ACTIVATEAPP
<00813> 000106A8 S WM_KILLFOCUS hwndGetFocus:(null)
<00814> 000106A8 R WM_KILLFOCUS
<00815> 000106A8 S WM_IME_SETCONTEXT fSet:0 iShow:C000000F
<00816> 000106A8 S WM_IME_NOTIFY dwCommand:IMN_CLOSESTATUSWINDOW dwCommand:00000001 dwData:00000000
<00817> 000106A8 R WM_IME_NOTIFY
<00818> 000106A8 R WM_IME_SETCONTEXT
<00819> 000106A8 S WM_DESTROY
<00820> 000106A8 R WM_DESTROY
<00821> 000106A8 S WM_NCDESTROY
<00822> 000106A8 R WM_NCDESTROY
支持(0) 反对(0) niechangxu | 园豆:69 (初学一级) | 2015-05-25 09:32

@niechangxu: 这个消息里都没有close啊, 你到底关了没

支持(0) 反对(0) 问天何必 | 园豆:3311 (老鸟四级) | 2015-05-25 17:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册