Hi,
I was trying to code a little application that will bring my desktop window to the foreground via a hotkey but I've encountered a problem. If I'm running a command prompt full screen, it remains in the foreground. When I hit my Start Menu button on the keyboard it switches me out of the command prompt and displays the start menu... how would I get my application to switch me out of the command prompt? I've tried GetForegroundWindow/SetForegroundWindow/ShowWindow combinations but nothing worked. Any help would be appreciated. :)
Thanks,
bl00dbath
I was trying to code a little application that will bring my desktop window to the foreground via a hotkey but I've encountered a problem. If I'm running a command prompt full screen, it remains in the foreground. When I hit my Start Menu button on the keyboard it switches me out of the command prompt and displays the start menu... how would I get my application to switch me out of the command prompt? I've tried GetForegroundWindow/SetForegroundWindow/ShowWindow combinations but nothing worked. Any help would be appreciated. :)
Thanks,
bl00dbath
What? I had some trouble with that 3 days ago. I almost smashed
my computer because of it :grin:. But hey you don't wanna know my
lifestory or something 'funny' like that :alright:.
After alot of testing with just about every api function I could get my
hands on. This is the only solution I found that should work 99.9%.
The code will give focus to the next window in the Z-order(cycling through
the whole z-order.)
Z-Order:
Toplevel, child, and pop-up windows recieve a position in the
Z-order according to their appearance on your screen.
Ex. When you set a window to be topmost, that window is the first
window in the Z-order.
my computer because of it :grin:. But hey you don't wanna know my
lifestory or something 'funny' like that :alright:.
After alot of testing with just about every api function I could get my
hands on. This is the only solution I found that should work 99.9%.
The code will give focus to the next window in the Z-order(cycling through
the whole z-order.)
Z-Order:
Toplevel, child, and pop-up windows recieve a position in the
Z-order according to their appearance on your screen.
Ex. When you set a window to be topmost, that window is the first
window in the Z-order.
invoke keybd_event, 18, 0, 0, 0 ;\\ Press 'ALT' Key
invoke keybd_event, 27, 0, 0, 0 ;\\ Press 'ESC' Key
invoke keybd_event, 27, 0, 2, 0 ;\\ Release 'ESC' Key
invoke keybd_event, 18, 0, 2, 0 ;\\ Release 'ALT' Key
Haha thanks for the reply Natas, I'll give it a try :)
Regards,
bl00dbath
Regards,
bl00dbath
You can try using the windows system wide hotkey 'windows key + m' to minimize all open windows. I'm not sure if that's exactly what you're trying to do but it will minimize all windows and bring up your desktop. It also minimizes full-screen dos windows. Another side note, 'alt+tab' will maximize/restore dos windows.
edit: Just look in windows.inc for the equates for the windows key and the m key. When you setup the hotkey in your app, sendmessage a wm_keydown or wm_char or whatever with that equate combo. I don't have the win api help file open but that should give you a start.
cheers,
will
edit: Just look in windows.inc for the equates for the windows key and the m key. When you setup the hotkey in your app, sendmessage a wm_keydown or wm_char or whatever with that equate combo. I don't have the win api help file open but that should give you a start.
cheers,
will
Thanks Will, that seems to work pretty well. :)
Regards,
bl00dbath
Regards,
bl00dbath
Window + D works too... You can try it too.
ShellExecute() + Desktop.scf ?
It maybe won't work on all windows versions...
It maybe won't work on all windows versions...
Thanks for all of the replys guys. :)
I have a problem though. When in a command prompt, if I hit Windows Key + M or D, I'm switched back to desktop no problems. But when my app is activated (I'm using a keyboard hook) and I try my hotkey from the command prompt, it doesn't work. It does work in all of the other normal windows though. Would it work better if I just setup a hotkey with say RegisterHotkey instead of using the keyboard hook?
Thanks,
bl00dbath
I have a problem though. When in a command prompt, if I hit Windows Key + M or D, I'm switched back to desktop no problems. But when my app is activated (I'm using a keyboard hook) and I try my hotkey from the command prompt, it doesn't work. It does work in all of the other normal windows though. Would it work better if I just setup a hotkey with say RegisterHotkey instead of using the keyboard hook?
Thanks,
bl00dbath