 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jonny
Joined: 13 Nov 2004 Posts: 3005 Location: Minnesota
|
Posted: Sun Nov 14, 2004 1:56 am Post subject: Alt+F4 Complements |
|
|
I always thought about Alt+F4, and why it's the only window function that has a straight hotkey in Windows. For that matter, why is it F4, instead of logically starting at F1? I'm sure it has some obscure historical explanation, but regardless, I made this script that makes the F2 and F3 keys press their respective buttons on the window. In the version of this I made for personal use, I also included Rajat's window shading script on F1, but I'm not sure if he'd let me release it, since I modified it to be compatible. If you can, Rajat, gimme a holler and I'll include your script in this thread. Anywho, here it is for now:
Alt+F2 = Minimize the active window
Alt+F3 = Maximize or restore the active window
| Code: | !F2::
; This workaround may be needed for some windows.
; If the conventional method won't work, uncomment
; this section and replace EditPad with whatever
; applications don't work.
;
; SetKeyDelay, 0 ;This allows the workaround to be as fast as WinMinimize
;
; WinGetTitle, WinTitle, A
;
; If WinTitle = EditPad Lite
; {
; Send, {ALT down} {ALT up}n ;To clarify, this is Alt+Space
; return
; }
;
; Else
; {
WinMinimize, A
return
; }
!F3::
; This one should be pretty self-explanatory.
; It simply checks to see whether the window
; is maximized or normal, then acts accordingly.
WinGet, MinMaxState, MinMax, A
if MinMaxState = 1
{
WinRestore, A
return
}
if MinMaxState = 0
{
WinMaximize, A
return
}
else
{
return
} |
I'm still working on the else {return} at the end; can someone tell me if that part is necessary? Would it dismiss it automatically if there was no active window? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Sun Nov 14, 2004 6:40 am Post subject: |
|
|
Looks good.
| Quote: | | I'm still working on the else {return} at the end; can someone tell me if that part is necessary? | It is necessary to "return" at all points where the flow of execution can reach; otherwise it will fall through to the next label/subroutine. In this case, it can be rewritten this way:
| Code: | WinGet, MinMaxState, MinMax, A
if MinMaxState in 1,-1 ; Because I think minimized windows can be active.
WinRestore, A
else
WinMaximize, A
return |
|
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3005 Location: Minnesota
|
Posted: Mon Nov 15, 2004 4:58 pm Post subject: |
|
|
Lol, I didn't know the braces weren't needed. I just saw them somewhere and I've used them ever since. New line works just as well apparently. My scripts should look a bit cleaner now. Oh, and thanks for the corrections.  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Mon Nov 15, 2004 5:10 pm Post subject: |
|
|
| Quote: | | New line works just as well apparently. | You do need braces if the section consists of more than one line. But for only one line, they are optional. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|