Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

HiRes Screen Splitter - Split your sreen like dual monitors


  • Please log in to reply
23 replies to this topic
JOnGliko
  • Members
  • 7 posts
  • Last active: Aug 28 2007 06:08 PM
  • Joined: 30 Aug 2006
;Split the screen in areas
;Really usefull for HiRes Monitor, make it look like dual monitor !
;
;
;Hotkey for the ACTIVE window--> WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9
;Hotkey for the window under the ACTIVE window--> WinKey + Alt + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9
;Special Hotkey --> Two Time on the Up arrow maximize the active window (num 0 on the pad do the same)
;Special Hotkey --> Two Time on the down arrow minimize the active window.

I have made this little script. It's really usefull for my 24" screen.
I know the script code is not optimize, but it work. Thx to tell me if you think that I can reduce the code size ;) or optimize.


;-------------------- 
;HiRes Screen Splitter -- by JOnGliko 
;-------------------- 
; 
;Split the screen in areas 
;Really usefull for HiRes Monitor, make it look like dual monitor ! 
; 
; 
;Hotkey for the ACTIVE window--> WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9 
;Hotkey for the window under the ACTIVE window--> WinKey + Alt + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9 
;Special Hotkey --> Two Time on the Up arrow maximize the active window (num 0 on the pad do the same) 
;Special Hotkey --> Two Time on the down arrow minimize the active window 
;_______________________________________________________________________ 


#Left:: 
#Numpad4:: ;put the Active window in the left part of the screen 
   ToLeft() 
Return 

#!Left:: 
#!Numpad4:: 
   Send, !{esc} 
   ToLeft() 
   Send, !+{esc} 
Return    
    
#Right:: 
#Numpad6::  ;put the Active window in the right part of the screen 
  ToRight() 
Return 

#!Right:: 
#!Numpad6:: 
   Send, !{esc} 
   ToRight() 
   Send, !+{esc} 
Return 

#Up:: 
#Numpad8:: 
if (A_PriorHotkey <> "#Up" or A_TimeSincePriorHotkey > 400) 
{ 
   KeyWait, Up 
   ToUp() ; One time key press put the Active window to top 
   return 
} 
   ToMaxi() ; Two time key press maximize the active window 
Return 

#!Numpad8:: 
#!Up:: 
   Send, !{esc} 
   ToUp() 
   Send, !+{esc} 
Return 

#Down:: 
#Numpad2:: 
if (A_PriorHotkey <> "#Down" or A_TimeSincePriorHotkey > 400) 
{ 
   KeyWait, Down 
   ToBottom()  ; One time key press put the window on the bottom 
   return 
} 
   WinMinimize, A ; Two time key press minimize the active window 
Return 

#!Down:: 
#!Numpad2:: 
   Send, !{esc} 
   ToBottom() 
   Send, !+{esc} 
Return 

#Numpad0:: ;Maximize 
   ToMaxi() 
Return        

#Numpad7:: ;put the Active window in the upper left corner 
   ToUpperLeft() 
Return 

#!Numpad7:: ;put the window in the upper left corner 
   Send, !{esc} 
   ToUpperLeft() 
   Send, !+{esc} 
Return 

#Numpad9:: ;put the Active window in the upper right corner 
   ToUpperRight() 
Return 

#!Numpad9:: ;put the window in the upper right corner 
   Send, !{esc} 
   ToUpperRight() 
   Send, !+{esc} 
Return 

#Numpad3:: ;put the Active window in the bottom right corner 
   ToBottomRight() 
Return 

#!Numpad3:: ;put the window in the bottom right corner 
   Send, !{esc} 
   ToBottomRight() 
   Send, !+{esc} 
Return 

#Numpad1:: ;put the Active window in the bottom left corner 
   ToBottomLeft() 
Return 

#!Numpad1:: ;put the window in the bottom left corner 
   Send, !{esc} 
   ToBottomLeft() 
   Send, !+{esc} 
Return 

#Numpad5:: ;Center the Active window 
   ToMiddle() 
Return 

#!Numpad5:: ;Center the window 
   Send, !{esc} 
   ToMiddle() 
   Send, !+{esc} 
Return 

ToUp() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,0,A_ScreenWidth,A_ScreenHeight/2-TrayHeight/2 
   Return 
} 
ToBottom() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,A_ScreenHeight/2-TrayHeight/2,A_ScreenWidth,A_ScreenHeight/2-TrayHeight/2 
   Return 
} 
ToLeft() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,0,A_ScreenWidth/2,A_ScreenHeight-TrayHeight 
   Return 
} 
ToRight() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight-TrayHeight 
   Return 
} 
ToMaxi() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,0,A_ScreenWidth,A_ScreenHeight-TrayHeight 
   Return 
} 
ToMiddle() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,A_ScreenWidth/4,0,A_ScreenWidth/2,A_ScreenHeight-TrayHeight 
   Return 
} 
ToUpperLeft() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,0,A_ScreenWidth/2,A_ScreenHeight/2-TrayHeight/2 
   Return 
} 
ToUpperRight() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight/2-TrayHeight/2 
   Return 
} 
ToBottomLeft() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,0,A_ScreenHeight/2-TrayHeight/2,A_ScreenWidth/2,A_ScreenHeight/2-TrayHeight/2 
} 
ToBottomRight() 
{ 
   WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, 
   WinMove,A,,A_ScreenWidth/2,A_ScreenHeight/2-TrayHeight/2,A_ScreenWidth/2,A_ScreenHeight/2-TrayHeight/2 
}


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I can see that this would be useful for big monitors or when using TV-out. Thanks for sharing it.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Hey, you didn't provided the big screen to test the script! :-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

MsgBox
  • Members
  • 204 posts
  • Last active: Jan 05 2011 01:40 AM
  • Joined: 17 Nov 2005
Hello JOnGliko

I know the script code is not optimize, but it work. Thx to tell me if you think that I can reduce the code size ;) or optimize.

As I said in your other post, I like this script, and for the last couple of days have been playing with it. :)

I have posted 2 versions below.

The first is an optimised (as far as I am able! :) ) version of your code.

The second is a bit different. Have a look and see what you think.

Instead of using the Alt modifier for the non active window, you just double press the appropriate numpad key (with "Win" pressed). More keys and key presses can be added!

Numpad Enter changes focus between the windows, and (pressing twice) swaps the window positions.

Thanks again for posting. 8)

;--------------------
;HiRes Screen Splitter -- by JOnGliko
;--------------------
;
;Split the screen in areas
;Really usefull for HiRes Monitor, make it look like dual monitor !
;
;
;Hotkey for the ACTIVE window--> WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9
;Hotkey for the window under the ACTIVE window--> WinKey + Alt + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9
;Special Hotkey --> Two Time on the Up arrow maximize the active window (num 0 on the pad do the same)
;Special Hotkey --> Two Time on the down arrow minimize the active window
;_______________________________________________________________________
#SingleInstance force

WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,, ; This line is only needed once.
                                                   ; so no need for the extra code.
Width:=A_ScreenWidth
Height:=A_ScreenHeight

#Left::
#Numpad4:: ;put the Active window in the left part of the screen
   WinMove,A,,0,0,Width/2,Height-TrayHeight
Return

#!Left::
#!Numpad4::
   Send, !{esc}
   WinMove,A,,0,0,Width/2,Height-TrayHeight
   Send, !+{esc}
Return

#Right::
#Numpad6::  ;put the Active window in the right part of the screen
   WinMove,A,,Width/2,0,Width/2,Height-TrayHeight
Return

#!Right::
#!Numpad6::
   Send, !{esc}
   WinMove,A,,Width/2,0,Width/2,Height-TrayHeight
   Send, !+{esc}
Return

#Up::
#Numpad8::
If ( A_PriorHotkey <> "#Down" or A_TimeSincePriorHotkey < 400)
{
   KeyWait, Up
   WinMove,A,,0,0,Width,Height/2-TrayHeight/2 ; One time key press put the Active window to top
   return
}
   WinMove,A,,0,0,Width,Height-TrayHeight ; Two time key press maximize the active window
Return

#!Numpad8::
#!Up::
   Send, !{esc}
   WinMove,A,,0,0,Width,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Down::
#Numpad2::
if (A_PriorHotkey <> "#Down" or A_TimeSincePriorHotkey > 400)
{
   KeyWait, Down
   WinMove,A,,0,Height/2-TrayHeight/2,Width,Height/2-TrayHeight/2  ; One time key press put the window on the bottom
   return
}
   WinMinimize, A ; Two time key press minimize the active window
Return

#!Down::
#!Numpad2::
   Send, !{esc}
   WinMove,A,,0,Height/2-TrayHeight/2,Width,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Numpad0:: ;Maximize
   WinMove,A,,0,0,Width,Height-TrayHeight
Return

#Numpad7:: ;put the Active window in the upper left corner
   WinMove,A,,0,0,Width/2,Height/2-TrayHeight/2
Return

#!Numpad7:: ;put the window in the upper left corner
   Send, !{esc}
   WinMove,A,,0,0,Width/2,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Numpad9:: ;put the Active window in the upper right corner
   WinMove,A,,Width/2,0,Width/2,Height/2-TrayHeight/2
Return

#!Numpad9:: ;put the window in the upper right corner
   Send, !{esc}
   WinMove,A,,Width/2,0,Width/2,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Numpad3:: ;put the Active window in the bottom right corner
   WinMove,A,,Width/2,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
Return

#!Numpad3:: ;put the window in the bottom right corner
   Send, !{esc}
   WinMove,A,,Width/2,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Numpad1:: ;put the Active window in the bottom left corner
   WinMove,A,,0,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
Return

#!Numpad1:: ;put the window in the bottom left corner
   Send, !{esc}
   WinMove,A,,0,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
   Send, !+{esc}
Return

#Numpad5:: ;Center the Active window
   WinMove,A,,Width/4,0,Width/2,Height-TrayHeight
Return

#!Numpad5:: ;Center the window
   Send, !{esc}
   WinMove,A,,Width/4,0,Width/2,Height-TrayHeight
   Send, !+{esc}
Return

;____________________________________
; \____HiRes Screen Splitter2_____/
;
; Coded By MsgBox                                           Last edit:- 02-09-06
;
; Based on "HiRes Screen Splitter" by JOnGliko
; http://www.autohotkey.com/forum/viewtopic.php?t=12229
;
;-------------------------------------------------------------------------------
;
; Split the screen in areas
; Really usefull for HiRes Monitor, make it look like dual monitor!
;
;------------------------------------------------ Quote:- JOnGliko -------------
;
; Hotkeys for the ACTIVE window (one key press).
; WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Hotkeys for the window under the ACTIVE window (two key presses).
; WinKey + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Keys 1 - 9 move the window to the screen position corresponding to the
; location of the number ie. 7 = top right, 9 = top left etc.
;
; Numpad 0 maximises the window/s. If the lower window is maximised, the focus
; is set to it.
; Numpad Enter swaps focus with 1 key press, and swaps the position of the
; windows with 2 key presses.

#UseHook
#SingleInstance force

WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,

Width := A_ScreenWidth
Height := A_ScreenHeight

Other = Up,Down,Left,Right,NumpadEnter       ; More can be added!

Loop Parse, Other, `,
   Hotkey #%A_LoopField%, Hoty
Loop 10 {
   no:=A_Index-1
   Hotkey #Numpad%no%, Hoty
   }
Return

Hoty:
   If ( A_ThisHotKey = A_PriorHotKey and A_TimeSincePriorHotkey < 250 )
      count++
   Else count = 1
   SetTimer KeyCheck, 275
Return

KeyCheck:
   SetTimer KeyCheck, Off
   IfGreater count, 2, SetEnv count,2     ; Limit no. of key presses to 2...
   key := A_ThisHotKey                    ; can be changed if more required.
   IfEqual key, #Left, SetEnv key,#Numpad4
   IfEqual key, #Right, SetEnv key,#Numpad6
   IfEqual key, #Up, SetEnv key,#Numpad8
   IfEqual key, #Down, SetEnv key,#Numpad2
   Gosub %Key%_%count%
Return

; Bottom left.
#Numpad1_1:
   WinMove,A,,0,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
Return
#Numpad1_2:
   Send, !{Esc}
   WinMove,A,,0,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad1_3:

; Bottom.
#Numpad2_1:
   WinMove,A,,0,Height/2-TrayHeight/2,Width,Height/2-TrayHeight/2
Return
#Numpad2_2:
   Send, !{Esc}
   WinMove,A,,0,Height/2-TrayHeight/2,Width,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad2_3:

; Bottom right
#Numpad3_1:
   WinMove,A,,Width/2,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
Return
#Numpad3_2:
   Send, !{Esc}
   WinMove,A,,Width/2,Height/2-TrayHeight/2,Width/2,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad3_3:

; Left.
#Numpad4_1:
   WinMove,A,,0,0,Width/2,Height-TrayHeight
Return
#Numpad4_2:
   Send, !{Esc}
   WinMove,A,,0,0,Width/2,Height-TrayHeight
   Send, !+{Esc}
Return
#Numpad4_3:

; Centre
#Numpad5_1:
   WinMove,A,,Width/4,0,Width/2,Height-TrayHeight
Return
#Numpad5_2:
   Send, !{Esc}
   WinMove,A,,Width/4,0,Width/2,Height-TrayHeight
   Send, !+{Esc}
Return
#Numpad5_3:

; Right.
#Numpad6_1:
   WinMove,A,,Width/2,0,Width/2,Height-TrayHeight
Return
#Numpad6_2:
   Send, !{Esc}
   WinMove,A,,Width/2,0,Width/2,Height-TrayHeight
   Send, !+{Esc}
Return
#Numpad6_3:

; Top left.
#Numpad7_1:
   WinMove,A,,0,0,Width/2,Height/2-TrayHeight/2
Return
#Numpad7_2:
   Send, !{Esc}
   WinMove,A,,0,0,Width/2,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad7_3:

; Top.
#Numpad8_1:
   WinMove,A,,0,0,Width,Height/2-TrayHeight/2
Return
#Numpad8_2:
   Send, !{Esc}
   WinMove,A,,0,0,Width,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad8_3:

; Top right.
#Numpad9_1:
   WinMove,A,,Width/2,0,Width/2,Height/2-TrayHeight/2
Return
#Numpad9_2:
   Send, !{Esc}
   WinMove,A,,Width/2,0,Width/2,Height/2-TrayHeight/2
   Send, !+{Esc}
Return
#Numpad9_3:

; Full.
#Numpad0_1:
   WinMove,A,,0,0,Width,Height-TrayHeight
Return
#Numpad0_2:
   Send, !{Esc}
   WinMove,A,,0,0,Width,Height-TrayHeight
   Send, !+{Esc}
   Send !{Tab}
Return
#Numpad0_3:

; 1 key press to switch focus to other window. (Alt-Tab)
; 2 key presses to swap the window positions.
#NumpadEnter_1:
   Send !{Tab}
Return
#NumpadEnter_2:
   WinGetPos xPosA, yPosA,wWidthA, wHeightA, A
   Send !{Tab}
   Sleep 50
   WinGetPos xPosB, yPosB,wWidthB, wHeightB, A
   WinMove A,, xPosA, yPosA,wWidthA, wHeightA
   Send !{Tab}
   Sleep 50
   WinMove A,, xPosB, yPosB,wWidthB, wHeightB
Return
#NumpadEnter_3:


JOnGliko
  • Members
  • 7 posts
  • Last active: Aug 28 2007 06:08 PM
  • Joined: 30 Aug 2006
Hi MsgBox,

I was without Internet conection, sorry for the delay.

Ok I understand my my var wasn't working. I use all ahk scripts in one file. It seems that the way I code was the only way for the code to work. I have to separate your version of the script in it's own .ahk file to see it work. Thx for the help.

Do you think that it's better to run 10 differents scripts or to run 1 ahk file with all your scripts (for the systeme resources) ?

For your version of HiRes2 I like it (same thing I have to run the script alone for it to work). It's better the two time to move the next active window ;). I like the winkek + numpad enter to change to swap windows.

I'll use for now you version ;) If I update the script I'll start working on your version.

Thx for the work and the help

MsgBox
  • Members
  • 204 posts
  • Last active: Jan 05 2011 01:40 AM
  • Joined: 17 Nov 2005
Hello JOnGliko

Do you think that it's better to run 10 differents scripts or to run 1 ahk file with all your scripts (for the systeme resources) ?

I usually try to combine my scripts rather than having lots of small ones running at the same time. For example, I have three scripts running constantly. One is what I would call my main script. It has all my window manipulation scripts, keyboard and mouse scripts, my screensaver etc. Another is is a script for my keyboard's special keys, F-Keys volume control etc. The last is a script that I have written for managing and viewing all of my hotkeys and hotstrings.

If I come across a script like yours that I want to keep, then depending on what it does, I decide which script to add it to.
Yours I have added to my main script...

I have to separate your version of the script in it's own .ahk file to see it work.

...like this:
Gosub HiResScreenSplitter2
This is placed in the auto execute section of my main script.

This part...
#UseHook
#SingleInstance force

WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,

Width := A_ScreenWidth
Height := A_ScreenHeight

Other = Up,Down,Left,Right,NumpadEnter       ; More can be added!

Loop Parse, Other, `,
   Hotkey #%A_LoopField%, Hoty
Loop 10 {
   no:=A_Index-1
   Hotkey #Numpad%no%, Hoty
   }
Return
now looks like this:
HiResScreenSplitter2:

WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,

Width := A_ScreenWidth
Height := A_ScreenHeight

Other = Up,Down,Left,Right,NumpadEnter       ; More can be added!

Loop Parse, Other, `,
   Hotkey #%A_LoopField%, Hoty
Loop 10 {
   no:=A_Index-1
   Hotkey #Numpad%no%, Hoty
   }
Return

As for system resources, I don't know. Somebody else might though!

For your version of HiRes2 I like it (same thing I have to run the script alone for it to work). It's better the two time to move the next active window

Thanks. :)
I used an idea I had for my keyboard script FKee3 which uses three key presses to launch various programs, run pieces of code etc.

I'll use for now you version ;) If I update the script I'll start working on your version.

Yes, go for it!
Don't forget to post any updates. :)

Posted Image

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
Hi, I had a similar idea and built it into deskman. i will compare it with my version to see which one is more efficient and how you use it.

http://www.autohotke...opic.php?t=8597

Similar Functions;
  Hotkey, <^>!Up    , HalfUp              ; Resize Window to take upper half  Sector( 1 + 2 )
  Hotkey, <^>!Down  , HalfDown            ; Resize Window to take lower half  Sector( 3 + 4 )
  Hotkey, <^>!Left  , HalfLeft            ; Resize Window to take left half  Sector( 1 + 3 )
  Hotkey, <^>!Right , HalfRight           ; Resize Window to take right half  Sector( 2 + 4 )
  Hotkey, <^>!Enter , MaximizeWindow      ; Resize; Maximize the window Sector( 1 + 2 + 3 + 4 )
  Hotkey, <^>!-     , TogglePaperSize     ; Resize; Make Portrait-Layout (A4) for reading purpouse
  Hotkey, #4        , TogglePaperSizeOn   ; Resize; A4
  Hotkey, #5        , TogglePaperSizeFull ; Resize; Fullscreen (hide taskbar)
  Hotkey, #6        , TogglePaperSizeOff  ; Resize; Maximize restore taskbar (Bug Desktop icons are gone)
  Hotkey, !F11      , SpecialFullScreen
  Hotkey, <^>!PgDn  , NextWindow          ; Alt-Esc (similar Alt-Tab) to Next Window (Task)
  Hotkey, <^>!PgUp  , PrevWindow          ; shift Alt-Esc (similar Alt-Tab) to Previous Window (Task)


Seems your script only works with taskbar on bottom. my script detects taskbar position and resizes windows with autodetect.
I use taskbar on right side (which you may prefer on your 24" window as you save some pixels 1600x50 > 1000 x50 !! the area is smaller and you have more than enough space in your taskbar on a big screen. )

you could improve your script a lot with using functions
look at my ResizeWin(x,y,w,h) function.

why do you move back and forth the active window all the time with !{esc} !+{esc} ?? is there a gui window in the way ?
perhaps you have a problem as you select taskbar and activate it this way ? WinGetPos,,,,TrayHeight,ahk_class Shell_TrayWnd,,,
perhaps you should unselect it once with !{esc} ???

the deskman.ahk is a little bit big but you can learn a bit about ahk with it, i plan to split it into two parts sometime, one for the windowmoving (perhaps more similar to your version) and the thumbnailing dock.

JOnGliko
  • Members
  • 7 posts
  • Last active: Aug 28 2007 06:08 PM
  • Joined: 30 Aug 2006
Hi, holomind

I have already seen your deskman script. After my first version of the script I was looking for a way to switch between the active window and the next active window. I have found in your script the "Alt-Esc (similar Alt-Tab) to Next Window (Task)".

As a beginner your script was too complicated for me (not so much time to pass on autohotkey too...).

I'll try your script, but it have lot's of function that I don't think I'll use. I'm using Niftywindows and the script already have lot's of feature.

I'm moving the active window with !{esc} because, I wanted to move the active window and the window just after, it was really important for me. So one hotkey to put the window on the right (for example) and an hotkey to put the next one on the left, without loosing the focus on your active window. Msgbox have improve the hotkey with two time on a key to move the next window.

Thx for your post I'll try your deskman and tell you about it after.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
Hi, Jongliko

i understand that the script is a bit too big, but i have put all my little annoyance-killers into it ;) ...

today i added some gesture detection also for moving the windows, to half or quarter sizes and i am quite satisfied with it. its more intuitive to just push windows to the screen or corner with your mouse, compared to keyboard. so ahk is also auto-hot-*gesture* ;) AHG ;)

i also had a function to move 2 windows at the same time into dualview. simulating a dualexplorer for copying windows. but i did not use it.
i move my windows when i need them, and also started to use quarter sizes to limit window-switching a lot. would be better on a 1600 or bigger screen, but with 1400x1050 its manageable. you have 4 normal vga to work at the same time. its 4times the size of this forum post form.

but really nice thing is to change your windowsizes quickly depending on context and not fiddle arround with the resizer on the bottom-right corner fo your windows, which is a big time killer. ...

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
Hi,

as you wrote about optimizing your code, i reformated your code to be better readably and also one could change the Hotkeys, but there is not so much choice when using numpad. but one could use parts of it to change it into gestures instead of hotkeys.

i split the Hotkey-Definition and Functions, so you dont have to hunt down the functions to change the hotkeys. its easier to change if all the hotkeys are defined at the top of the script.
; Hotkey definition
...

instead of
  #Numpad1::Gosub, Move_Bottom_Left

one could write
  Hotkey #Numpad1, Gosub, Move_Bottom_Left

But this did not work all the time , as Gosub %key% calls the funtion, which seems not to work if defined with Hotkey function.

;____________________________________
; \____HiRes Screen Splitter2_____/
;
; Modified by HoloMind										Last edit:- 10-09-06
;
; Coded By MsgBox                                           Last edit:- 02-09-06
;
; Based on "HiRes Screen Splitter" by JOnGliko
; http://www.autohotkey.com/forum/viewtopic.php?t=12229
;
;-------------------------------------------------------------------------------
;
; Split the screen in areas
; Really usefull for HiRes Monitor, make it look like dual monitor!
;
;------------------------------------------------ Quote:- JOnGliko -------------
;
; Hotkeys for the ACTIVE window (one key press).
; WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Hotkeys for the window under the ACTIVE window (two key presses).
; WinKey + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Keys 1 - 9 move the window to the screen position corresponding to the
; location of the number ie. 7 = top right, 9 = top left etc.
;
; Numpad 0 maximises the window/s. If the lower window is maximised, the focus
; is set to it.
; Numpad Enter swaps focus with 1 key press, and swaps the position of the
; windows with 2 key presses.

#UseHook
#SingleInstance force

Main:
	Gosub, DetectScreen
	Gosub, AssignHotkeys
Return

; Hotkey defintion
#Numpad1::Gosub, Move_Bottom_Left
#Numpad2::Gosub, Move_Bottom
#Numpad3::Gosub, Move_Bottom_Right
#Numpad4::Gosub, Move_Left
#Numpad5::Gosub, Move_Center
#Numpad6::Gosub, Move_Right
#Numpad7::Gosub, Move_Top_Left
#Numpad8::Gosub, Move_Top
#Numpad9::Gosub, Move_Top_Right
#Numpad0::Gosub, Move_Full
#NumpadEnter::Gosub, Move_Last

DetectScreen: 
	WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,

	Sw := A_ScreenWidth
	Sh := A_ScreenHeight

	; Define Work-Area (adjust Taskbar position)
	Wy :=      ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th
	Wx :=      ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw
	Wh := Sh - ( Tw > Th  ) * Th
	Ww := Sw - ( Tw < Th  ) * Tw
Return

AssignHotkeys:
	Other = Up,Down,Left,Right,NumpadEnter       ; More can be added!

	Loop Parse, Other, `,
	   Hotkey #%A_LoopField%, Hoty
	Loop 10 {
	   no:=A_Index-1
	   Hotkey #Numpad%no%, Hoty
   }
Return

Hoty:
   If ( A_ThisHotKey = A_PriorHotKey and A_TimeSincePriorHotkey < 250 )
      key_repeat_count++
   Else key_repeat_count = 1
   SetTimer KeyCheck, 275
Return

KeyCheck:
   SetTimer KeyCheck, Off
   IfGreater key_repeat_count, 2, SetEnv key_repeat_count,2     ; Limit no. of key presses to 2...
   key := A_ThisHotKey                    ; can be changed if more required.
   IfEqual key, #Left  , SetEnv key,#Numpad4
   IfEqual key, #Right , SetEnv key,#Numpad6
   IfEqual key, #Up    , SetEnv key,#Numpad8
   IfEqual key, #Down  , SetEnv key,#Numpad2
   Gosub %Key%
Return
; config of which keys


WinMove_Zoom( _x , _y , _w , _h )
{
   global Ww, Wh, Wx, Wy, key_repeat_count 
   IfEqual key_repeat_count , 2 , Send, !{Esc}
   WinMove,A, , Wx + ceil( Ww * _x ), Wy + ceil( Wh * _y ) , 0 + ceil( Ww * _w ) , 0 + ceil( Wh * _h )
   IfEqual key_repeat_count , 2 , Send, !+{Esc}
}


Move_Bottom_Left: 
	WinMove_Zoom( 0, .5, .5, .5 )
Return

Move_Bottom: 
	WinMove_Zoom( 0, .5, 1 , .5 )
Return

Move_Bottom_Right:
	WinMove_Zoom( .5, .5, .5, .5 )
Return

Move_Left:
	WinMove_Zoom( 0, 0, .5, 1 )
Return

Move_Center:
	WinMove_Zoom( .25, 0, .5, 1 )
Return

Move_Right:
	WinMove_Zoom( .5, 0, .5, 1 )
Return

Move_Top_Left:
	WinMove_Zoom( 0, 0, .5, .5 )
Return

Move_Top:
	WinMove_Zoom( 0, 0, 1, .5 )
Return

Move_Top_Right:
	WinMove_Zoom( .5, 0, .5, .5 )
Return

Move_Full:
	WinMove_Zoom( 0, 0, 1, 1 )
	if ( key_repeat_count = 2 )
	{
		Send, !{Tab} 
	}
Return

; 1 key press to switch focus to other window. (Alt-Tab)
; 2 key presses to swap the window positions.
Move_Last:
	if ( key_repeat_count = 1 )
	{
		Send, !{Tab}
	}
    
    if ( key_repeat_count = 2 )
	{	
		WinGetPos xPosA, yPosA,wWidthA, wHeightA, A
		Send !{Tab}
		Sleep 50
		WinGetPos xPosB, yPosB,wWidthB, wHeightB, A
		WinMove A,, xPosA, yPosA,wWidthA, wHeightA
		Send !{Tab}
		Sleep 50
		WinMove A,, xPosB, yPosB,wWidthB, wHeightB
	}	
Return



holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
Hi, here is another version of this script with gestures added.
With this you can Assign the Windowsize also with right drag up for Move_Top etc. it shows a small tooltip with direction and you can choose.
look for the XX_Action in the definnition to see which gestures are defined.
(in General Drag Up moves window to half up, etc. Drag Up then Right, quarter size in up-right corner. etc. you have to right-drag your mouse 50pixels to apply a gesture. if you dont want cancel this gesture simply drag until you have 3 letters like LLL.

This one is the same feature as in DeskMan, but this version looks much easier. Perhaps i will use this one in DeskMan and splitt the Deskman.ahk, which is too complicated for many.

The gesturefunction looks quite complicated perhaps somebody finds a way to clean up the code. (from RButton:: ... on)
if you want to put this funktion on MButton (Middle Button) simply replace RButton with MButton in the whole script.

;____________________________________
; \____HiRes Screen Splitter2_____/
;
; Modified by HoloMind										Last edit:- 10-09-06
; -- code restructure
; -- gestures added
;
; Coded By MsgBox                                           Last edit:- 02-09-06
;
; Based on "HiRes Screen Splitter" by JOnGliko
; http://www.autohotkey.com/forum/viewtopic.php?t=12229
;
;-------------------------------------------------------------------------------
;
; Split the screen in areas
; Really usefull for HiRes Monitor, make it look like dual monitor!
;
;------------------------------------------------ Quote:- JOnGliko -------------
;
; Hotkeys for the ACTIVE window (one key press).
; WinKey + Arrow direction && WinKey + Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Hotkeys for the window under the ACTIVE window (two key presses).
; WinKey + Arrow direction && WinKey + Alt Numpad 1 2 3 4 5 6 7 8 9 0 Enter
;
; Keys 1 - 9 move the window to the screen position corresponding to the
; location of the number ie. 7 = top right, 9 = top left etc.
;
; Numpad 0 maximises the window/s. If the lower window is maximised, the focus
; is set to it.
; Numpad Enter swaps focus with 1 key press, and swaps the position of the
; windows with 2 key presses.

#UseHook
#SingleInstance force


Main:
	Gosub, GestureVars
	Gosub, DetectScreen
	Gosub, AssignHotkeys
Return

GestureVars: 
	; --------------- gestures
	SetMouseDelay 			-1
	SetDefaultMouseSpeed 	0
	mg_active 				= 0
	timeout 				= 100		; approx. half a second
	sensitivity 			= 50		; this many pixels required before being accepted
	gestures 				= -L-R-U-D-UU-DD-UL-UR-DR-DL-LL-RR-
	excluded 				= Pixia	
	disabled 				= Minesweeper,Cheat Mine
Return

; Hotkey and gesture definition ( Gesture = (D)own, (L)eft , (U)p, (R)ight )
#Numpad1::
DL_Action:
	Gosub, Move_Bottom_Left
return

#Numpad2::
D_Action: 
	Gosub, Move_Bottom
return

#Numpad3::
DR_Action:
	Gosub, Move_Bottom_Right
return

#Numpad4::
L_Action:
	Gosub, Move_Left
return

#Numpad5::
DD_Action:
	Gosub, Move_Center
return

#Numpad6::
R_Action:
	Gosub, Move_Right
return

#Numpad7::
UL_Action:
	Gosub, Move_Top_Left
return

#Numpad8::
U_Action:
	Gosub, Move_Top
return

#Numpad9::
UR_Action:
	Gosub, Move_Top_Right
return

#Numpad0::
UU_Action:
	Gosub, Move_Full
return

#NumpadEnter::
LL_Action:
	Gosub, Move_Last
return

RR_Action:
	key_repeat_count = 2
	Gosub, Move_Last
	key_repeat_count = 1
return

DetectScreen: 
	WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,

	Sw := A_ScreenWidth
	Sh := A_ScreenHeight

	; Define Work-Area (adjust Taskbar position)
	Wy :=      ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th
	Wx :=      ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw
	Wh := Sh - ( Tw > Th  ) * Th
	Ww := Sw - ( Tw < Th  ) * Tw
Return

AssignHotkeys:
	Other = Up,Down,Left,Right,NumpadEnter       ; More can be added!

	Loop Parse, Other, `,
	   Hotkey #%A_LoopField%, Hoty
	Loop 10 {
	   no:=A_Index-1
	   Hotkey #Numpad%no%, Hoty
   }
Return

Hoty:
   If ( A_ThisHotKey = A_PriorHotKey and A_TimeSincePriorHotkey < 250 )
      key_repeat_count++
   Else key_repeat_count = 1
   SetTimer KeyCheck, 275
Return

KeyCheck:
   SetTimer KeyCheck, Off
   IfGreater key_repeat_count, 2, SetEnv key_repeat_count,2     ; Limit no. of key presses to 2...
   key := A_ThisHotKey                    ; can be changed if more required.
   IfEqual key, #Left  , SetEnv key,#Numpad4
   IfEqual key, #Right , SetEnv key,#Numpad6
   IfEqual key, #Up    , SetEnv key,#Numpad8
   IfEqual key, #Down  , SetEnv key,#Numpad2
   Gosub %Key%
Return
; config of which keys


WinMove_Zoom( _x , _y , _w , _h )
{
   global Ww, Wh, Wx, Wy, key_repeat_count 
   IfEqual key_repeat_count , 2 , Send, !{Esc}
   WinMove,A, , Wx + ceil( Ww * _x ), Wy + ceil( Wh * _y ) , 0 + ceil( Ww * _w ) , 0 + ceil( Wh * _h )
   IfEqual key_repeat_count , 2 , Send, !+{Esc}
}


Move_Bottom_Left: 
	WinMove_Zoom( 0, .5, .5, .5 )
Return

Move_Bottom: 
	WinMove_Zoom( 0, .5, 1 , .5 )
Return

Move_Bottom_Right:
	WinMove_Zoom( .5, .5, .5, .5 )
Return

Move_Left:
	WinMove_Zoom( 0, 0, .5, 1 )
Return

Move_Center:
	WinMove_Zoom( .25, 0, .5, 1 )
Return

Move_Right:
	WinMove_Zoom( .5, 0, .5, 1 )
Return

Move_Top_Left:
	WinMove_Zoom( 0, 0, .5, .5 )
Return

Move_Top:
	WinMove_Zoom( 0, 0, 1, .5 )
Return

Move_Top_Right:
	WinMove_Zoom( .5, 0, .5, .5 )
Return

Move_Full:
	WinMove_Zoom( 0, 0, 1, 1 )
	if ( key_repeat_count = 2 )
	{
		Send, !{Tab} 
	}
Return

; 1 key press to switch focus to other window. (Alt-Tab)
; 2 key presses to swap the window positions.
Move_Last:
	if ( key_repeat_count < 2 )
	{
		Send, !{Tab}
	}
    
    if ( key_repeat_count = 2 )
	{	
		WinGetPos xPosA, yPosA,wWidthA, wHeightA, A
		Send !{Tab}
		Sleep 50
		WinGetPos xPosB, yPosB,wWidthB, wHeightB, A
		WinMove A,, xPosA, yPosA,wWidthA, wHeightA
		Send !{Tab}
		Sleep 50
		WinMove A,, xPosB, yPosB,wWidthB, wHeightB
	}	
Return

; some stuff for gesture-detection

RButton::
 
  MouseGetPos,,, id
  WinGetTitle mg_title, ahk_id %id%
  if mg_title contains %disabled%
    Suspend
  else if mg_title not contains %excluded%
  {
    mg_active = 1
    mg_executed = 0
    mg_rheld = 0
    mg_str =
    mg_idletime = 0
    ifEqual mg_show,, ToolTip %A_Space%
    MouseGetPos px, py
    px2 = %px%
    py2 = %py%
    loop
    {
      GetKeyState st, RButton, P
      if st = U
      {
	ifEqual mg_show,, ToolTip
	if mg_rheld = 0
	{
	  mg_active = 0
	  if mg_executed = 0
	  if mg_str =
	    MouseClick R
	  else ifInString gestures, -%mg_str%-
	    gosub %mg_str%_Action
          else ifEqual mg_rclick,,
	    MouseClick R
	}
	else
	  MouseClick R,,,,,U
	return
      }
      else if mg_idletime < %timeout%
      {
	MouseGetPos dx, dy
	dx -= %px2%
	dy -= %py2%
	if dx > %sensitivity%
	  mg_dir = R
	else if dx < -%sensitivity%
	  mg_dir = L
	else if dy > %sensitivity%
	  mg_dir = D
	else if dy < -%sensitivity%
	  mg_dir = U
	if mg_dir <>
	{
	  mg_str = %mg_str%%mg_dir%
	  ifEqual mg_show,, ToolTip %mg_str%
	  MouseGetPos px2, py2
	  mg_idletime = 0
	  mg_dir =
	}
	else
	  mg_idletime++
      }
      else
      if mg_rheld = 0
      if mg_executed = 0
      {
	MouseGetPos px2, py2
	if px2 <> %px%
	if py2 <> %py%
	{
	  ifEqual mg_show,, ToolTip
	  MouseClick R, %px%, %py%,,,D
	  MouseMove %px2%, %py2%
	  mg_rheld = 1
	  mg_active = 0
	}
      }
      Sleep 10
    }
  }
  mb = R
goto ButtonWait

ButtonWait:
  MouseClick %mb%,,,,,D
  loop
  {
    GetKeyState st, %mb%Button, P
    ifEqual st, U, break
    Sleep 10
  }
  MouseClick %mb%,,,,,U
return



holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
I did not really understand why you move windows away with !esc !+esc.
there must be one window in front which you dont want to loose ? like an InstantMessenger ? you should make this window clickthrough (always on top disabled) so it does not mess up your other windows.

perhaps a program like ghost-it is what you need.

http://home.rocheste...rtcfox/GhostIt/

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
The ScreenDetect function could be even easier, found it in lazlos scripts.

ScreenDetect: 
  SysGet W, MonitorWorkArea
  WW := WRight-WLeft 
  WH := WBottom-WTop
return

only need to change some variable names.
no need to caclculate difference of desktop and taskbar.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
I used some script of Lazlo and applied the Numkeys on it. so this is the minimal version of the script (fully functional , but without the !{esc} !+{esc} stuff which i dont understand. also the funny special alt-tab is missing.
but it shows how small you can get with ahk

#SingleInstance force
SysGet m, MonitorWorkArea
mW  := mRight-mLeft
mH  := mBottom-mTop

#Numpad7::WinMove, A,, mLeft		,mTop		,mW/2	,mH/2		; Top Left  	H H 
#Numpad8::WinMove, A,, mLeft		,mTop		,mW		,mH/2		; Top       	F H
#Numpad9::WinMove, A,, mLeft+mW/2	,mTop		,mW/2	,mH/2		; Top Right 	H H 
#Numpad4::WinMove, A,, mLeft		,mTop		,mW/2	,mH			; Left			H F
#Numpad5::WinMove, A,, mLeft+mW/4	,mTop		,mW/2	,mH			; Center		H F 
#Numpad6::WinMove, A,, mLeft+mW/2	,mTop		,mW/2	,mH			; Right			H F
#Numpad1::WinMove, A,, mLeft		,mTop+mH/2	,mW/2	,mH/2		; Bottom Left 	H H
#Numpad2::WinMove, A,, mLeft		,mTop+mH/2	,mW 	,mH/2		; Bottom 		H F
#Numpad3::WinMove, A,, mLeft+mW/2	,mTop+mH/2	,mW/2	,mH/2		; Bottom Right 	H H
#NumpadEnter::WinMove, A,, mLeft	,mTop	 	,mW		,mH			; Full			F F

now, nobody can say my scripts are to long *lol*

  • Guests
  • Last active:
  • Joined: --
That last script is hotness, thanks! :D