473,218 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 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 9010
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

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

Similar topics

by: MLH | last post by:
On the subject of switching between virtual consoles to get out of a 'hung' situation in the primary console... What I have been doing is pressing LEFTALT-F4 to bring up a 2nd virtual console,...
by: Ron James | last post by:
I have a Dialog type form that starts a worker thread, allows the thread to update its progess and provides a Cancel button. Following advice from Chad Meyers in a recent posting, the worker...
by: Stefan | last post by:
Hy, a have an application and i must disable the follow combination of keys: ALT+F4 ALT+TAB CTRL+ALT+DEL CTRL+ESC. For ALT+F4 i can disable the conbination with: protected override...
by: Stefan | last post by:
Hy, i have an app and i must disable this combination: ALT+F4; CTRL+ALT+DEL; CTRL+ESC;ALT+TAB like this: i find something on Internet and i can block ALT+F4 protected override...
by: 007 | last post by:
I have a FixedToolWindow form that I create and display when the user presses a button on the toolbar. I want to prevent Alt+F4 on the FixedToolWindow form. How do I accomplish this? I want the...
by: cashdeskmac | last post by:
I have written a small program and I want the user to close it down solely by clicking on a button. How can I disable the ALT+F4 method of closing the application down?
by: Nikki | last post by:
Hi, Can anybody help me, i want to prevent windows to close my winform of ..NET application, when user presses Alt+F4
by: Michael Maes | last post by:
Hello, ALT+F4 is the shortcut to close a form. When I use this shortcut in an MDI enviroment, the application is closed, so obviously the shortcut applies to the 'Container' and not to the...
by: freelancex | last post by:
Hi, Im new to this forum, and new to scripting in general. Im an ICT Technician for a high school and i am designing a Form in visual basic 2005. The intended purpose of the Form, is to prevent...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.