AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Alt+F4 Complements

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
jonny



Joined: 13 Nov 2004
Posts: 3005
Location: Minnesota

PostPosted: Sun Nov 14, 2004 1:56 am    Post subject: Alt+F4 Complements Reply with quote

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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Sun Nov 14, 2004 6:40 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jonny



Joined: 13 Nov 2004
Posts: 3005
Location: Minnesota

PostPosted: Mon Nov 15, 2004 4:58 pm    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Mon Nov 15, 2004 5:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group