Ctrl Alt F4
-
This is so terribly embarrassing. An old dog like myself shouldn't be asking such stupid questions, but for the life of me I'm can't find the right switch to flip. Of course, I knew I was in trouble when I heard myself mutter, "All I wanted to do was..." :doh: IE7 has a convoluted Ctrl+Alt+F4 combination to close all but the current tab (best as I can determine from Google, etc., there is no Tabs API, bizarre as that may be). So, in a toolbar I wrote, I simply wanted to add a button so the user could click to close all tabs instead of playing a game of Twister with their fingers. WM_KEYDOWN, SendInput, Get/SetKeyboardState, I've screwed around with all of this, but I can't seem to find the proper approach to send this particular keystroke combination. Of course, it's the combination of Ctrl and Alt that is the complicating factor. So, how 'bout it - any of you old dogs (or all the young dogs who are much brighter than I am) know how to accomplish this? It really feels like one of those solutions that's going to be so simple as to make me feel quite inept once discovered, but hey, I've been there before. :) Thanks for any insights you might offer.
Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
-
This is so terribly embarrassing. An old dog like myself shouldn't be asking such stupid questions, but for the life of me I'm can't find the right switch to flip. Of course, I knew I was in trouble when I heard myself mutter, "All I wanted to do was..." :doh: IE7 has a convoluted Ctrl+Alt+F4 combination to close all but the current tab (best as I can determine from Google, etc., there is no Tabs API, bizarre as that may be). So, in a toolbar I wrote, I simply wanted to add a button so the user could click to close all tabs instead of playing a game of Twister with their fingers. WM_KEYDOWN, SendInput, Get/SetKeyboardState, I've screwed around with all of this, but I can't seem to find the proper approach to send this particular keystroke combination. Of course, it's the combination of Ctrl and Alt that is the complicating factor. So, how 'bout it - any of you old dogs (or all the young dogs who are much brighter than I am) know how to accomplish this? It really feels like one of those solutions that's going to be so simple as to make me feel quite inept once discovered, but hey, I've been there before. :) Thanks for any insights you might offer.
Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
I don't know how to send keys but there is an article KeyStrokeEngine[^]. I just tried the demo application and it can successfully send CTRL+ALT+F4 to IE. Maybe looking into source will tell you how to post a message yourself. -Saurabh
modified on Tuesday, April 29, 2008 10:36 PM
-
I don't know how to send keys but there is an article KeyStrokeEngine[^]. I just tried the demo application and it can successfully send CTRL+ALT+F4 to IE. Maybe looking into source will tell you how to post a message yourself. -Saurabh
modified on Tuesday, April 29, 2008 10:36 PM
Hi, Saurabh. I looked over his code, seems to be a nice piece of work. Reviewing it put me onto keybd_event(), which is an approach I hadn't been aware of (probably because it's been superceded by the somewhat more convoluted SendInput()). keybd_event() is pretty straightforward to use, and when I plugged in the key down and then key up calls for control, alt and F4, it worked like a charm. For those who may be interested, here's the snippet that got it done:
// key down for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,0 , 0); keybd_event(VK_MENU,0xb8,0 , 0); keybd_event(VK_F4,0,0 , 0); // key up for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); keybd_event(VK_F4,0, KEYEVENTF_KEYUP,0);
Thanks very much for taking the time to help me - I do appreciate it! :)Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
-
Hi, Saurabh. I looked over his code, seems to be a nice piece of work. Reviewing it put me onto keybd_event(), which is an approach I hadn't been aware of (probably because it's been superceded by the somewhat more convoluted SendInput()). keybd_event() is pretty straightforward to use, and when I plugged in the key down and then key up calls for control, alt and F4, it worked like a charm. For those who may be interested, here's the snippet that got it done:
// key down for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,0 , 0); keybd_event(VK_MENU,0xb8,0 , 0); keybd_event(VK_F4,0,0 , 0); // key up for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); keybd_event(VK_F4,0, KEYEVENTF_KEYUP,0);
Thanks very much for taking the time to help me - I do appreciate it! :)Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
Hey Chris, You are most welcome and thanks for the code snippet. -Saurabh
-
Hi, Saurabh. I looked over his code, seems to be a nice piece of work. Reviewing it put me onto keybd_event(), which is an approach I hadn't been aware of (probably because it's been superceded by the somewhat more convoluted SendInput()). keybd_event() is pretty straightforward to use, and when I plugged in the key down and then key up calls for control, alt and F4, it worked like a charm. For those who may be interested, here's the snippet that got it done:
// key down for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,0 , 0); keybd_event(VK_MENU,0xb8,0 , 0); keybd_event(VK_F4,0,0 , 0); // key up for ctrl, alt and F4 keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); keybd_event(VK_MENU,0xb8,KEYEVENTF_KEYUP,0); keybd_event(VK_F4,0, KEYEVENTF_KEYUP,0);
Thanks very much for taking the time to help me - I do appreciate it! :)Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
Hello sir. It looks like your problem is solved. Good to know about that. I was really surprised to see you post a question here. Honestly, I never ever thought that I will see someone like you to post a question here. :) BTW, I have been a great admirer of your articles. :)
Regards, Vijay.
-
Hello sir. It looks like your problem is solved. Good to know about that. I was really surprised to see you post a question here. Honestly, I never ever thought that I will see someone like you to post a question here. :) BTW, I have been a great admirer of your articles. :)
Regards, Vijay.
Hi, Vijay. Thanks for the kind words, man - glad you enjoy my ramblings. As for asking questions, hey, I'm just a geek like everyone else around here. Some days are good, some days are okay, and some days the screen turns a particularly interesting shade of the color blue. :-D
Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
-
Hi, Vijay. Thanks for the kind words, man - glad you enjoy my ramblings. As for asking questions, hey, I'm just a geek like everyone else around here. Some days are good, some days are okay, and some days the screen turns a particularly interesting shade of the color blue. :-D
Christopher Duncan Author of The Career Programmer and Unite the Tribes Coming soon: Got a career question? Ask the Attack Chihuahua! www.PracticalUSA.com
When I entered the forum here today, I saw your post at the top and just asked myself -"Am I in the Lounge?". I had to check once to make sure that I was in the C++ forum and not in the Lounge. :)
Christopher Duncan wrote:
hey, I'm just a geek like everyone else around here. Some days are good, some days are okay, and some days the screen turns a particularly interesting shade of the color blue.
Yes, but I believed that people with reputation as high as yours either don't face any problem while programming or they restrain themselves from asking for help here if they face any. But its really nice to see you post a question and ask for help here. ;)
Regards, Vijay.
-
When I entered the forum here today, I saw your post at the top and just asked myself -"Am I in the Lounge?". I had to check once to make sure that I was in the C++ forum and not in the Lounge. :)
Christopher Duncan wrote:
hey, I'm just a geek like everyone else around here. Some days are good, some days are okay, and some days the screen turns a particularly interesting shade of the color blue.
Yes, but I believed that people with reputation as high as yours either don't face any problem while programming or they restrain themselves from asking for help here if they face any. But its really nice to see you post a question and ask for help here. ;)
Regards, Vijay.
The biggest wisemen are always those that know where their limits are and are not afraid to recognise that they have errors/questions as the rest of the "mortal" people, although less ;)
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson