AutoHotkey Community

It is currently May 27th, 2012, 9:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Alt+F4 Complements
PostPosted: November 14th, 2004, 1:56 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2004, 6:40 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2004, 4:58 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2004, 5:10 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, nomissenrojb, Stigg and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group