Hello JOnGliko
JOnGliko wrote:
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.
Code:
;--------------------
;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
Code:
;____________________________________
; \____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: