471,325 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

How to use SendMessage to sent ALT+F4 or Alt+f+x

Hi All,

I'm trying to close a browser window either by sending Alt+f4 or Alt+f to open the file menu and then 'x' to exit and am trying to achieve this using win32api.SendMessage(). I tried all combinations of WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, VK_MENU and VK_F4 but couldn't get this.
I'm stuck on this one since two days and I really appreciate any help.
I can't use sendkeys since this window is not always in focus. I can't also use
SendMessage(hwnd, win32con.WM_SYSCOMMAND, win32con.VK_CLOSE, 1) since there are some additional dialogs need to be handles upon close.
(like the confirmation dialog for closing tabs)

On a similar note can someone explain whats the last parameter used in SendMessage. I'm able to send 'tab' to a dialog using SendMessage(hwnd, win32con.WM_CHAR, win32con.VK_TAB, 1) but its not successful all the time if I replace 1 with 0 (the last param)

Thanks in Advance!
Sep 13 '07 #1
3 8540
bartonc
6,596 Expert 4TB
The entire Win32 API is documented in the MSDN Liibrary. That particular page is here.
Sep 13 '07 #2
The entire Win32 API is documented in the MSDN Liibrary. That particular page is here.
I did go through the page before and I was successfully able to send keystrokes to he window which are not special. The only problem I couldn't have a solution for is sending the combination of two keys eg: Alt+F4.
Please provide a sequence of steps which could do this.
Sep 14 '07 #3
Can someone please help me with this? sending ALT+f to a window is what I need.
Sep 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Ron James | last post: by
reply views Thread by Stefan | last post: by
3 posts views Thread by 007 | last post: by
2 posts views Thread by cashdeskmac | last post: by
7 posts views Thread by Michael Maes | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.