@@ -27,6 +27,10 @@ global APP_SHORTCUT_TOPCENTERSIXTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHOR
27
27
global APP_SHORTCUT_BOTTOMCENTERSIXTH := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " BottomCenterSixth" , " ^#m" )
28
28
global APP_SHORTCUT_LEFTHALF := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " LeftHalf" , " ^#[" )
29
29
global APP_SHORTCUT_RIGHTHALF := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " RightHalf" , " ^#]" )
30
+ global APP_SHORTCUT_TOPLEFT := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " TopLeft" , " ^#u" )
31
+ global APP_SHORTCUT_TOPRIGHT := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " TopRight" , " ^#i" )
32
+ global APP_SHORTCUT_BOTTOMLEFT := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " BottomLeft" , " ^#j" )
33
+ global APP_SHORTCUT_BOTTOMRIGHT := IniRead (APP_INI_FILE, APP_INI_SECTION_SHORTCUT, " BottomRight" , " ^#k" )
30
34
31
35
; --Tooltip
32
36
A_IconTip := APP_NAME
@@ -132,6 +136,10 @@ Hotkey(APP_SHORTCUT_TOPCENTERSIXTH, TopCenterSixth)
132
136
Hotkey (APP_SHORTCUT_BOTTOMCENTERSIXTH, BottomCenterSixth)
133
137
Hotkey (APP_SHORTCUT_LEFTHALF, LeftHalf)
134
138
Hotkey (APP_SHORTCUT_RIGHTHALF, RightHalf)
139
+ Hotkey (APP_SHORTCUT_TOPLEFT, TopLeft)
140
+ Hotkey (APP_SHORTCUT_TOPRIGHT, TopRight)
141
+ Hotkey (APP_SHORTCUT_BOTTOMLEFT, BottomLeft)
142
+ Hotkey (APP_SHORTCUT_BOTTOMRIGHT, BottomRight)
135
143
136
144
Center(* )
137
145
{
@@ -721,6 +729,163 @@ RightHalf(*)
721
729
}
722
730
}
723
731
732
+ TopLeft(* )
733
+ {
734
+ ; -- Get the handle of the active window
735
+ hWnd := WinExist (" A" )
736
+ if (hWnd <= 0 )
737
+ return
738
+
739
+ ; -- Get the number of monitors
740
+ MonitorCount := MonitorGetCount()
741
+
742
+ ; -- Get the dimensions of the current window
743
+ WinGetPosEx(hWnd, & x, & y, & w, & h, & ofl, & oft, & ofr, & ofb)
744
+
745
+ ; -- Loop through each monitor to find which one contains the active window
746
+ Loop MonitorCount
747
+ {
748
+ ; -- Get the dimensions of the current monitor
749
+ MonitorGetWorkArea(A_Index , & l, & t, & r, & b)
750
+
751
+ ; -- Check if the active window is within the current monitor
752
+ if (CheckWindowWithinMonitor(x, y, w, h, ofl, ofr, oft, ofb, r, l, t, b))
753
+ {
754
+ ; -- Calculate the width as half of the monitor
755
+ HalfWidth := Ceil ((r - l) / 2 )
756
+
757
+ ; -- Set the window position to the left half of the monitor and top half of it
758
+ WinMove (l - ofl, t - oft, HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
759
+
760
+ ; -- Show layout toast
761
+ Toast(" Top Left" , r, l, t, b)
762
+
763
+ ; -- Exit the loop since we found the correct monitor
764
+ break
765
+ }
766
+ }
767
+ }
768
+
769
+ TopRight(* )
770
+ {
771
+ ; -- Get the handle of the active window
772
+ hWnd := WinExist (" A" )
773
+ if (hWnd <= 0 )
774
+ return
775
+
776
+ ; -- Get the number of monitors
777
+ MonitorCount := MonitorGetCount()
778
+
779
+ ; -- Get the dimensions of the current window
780
+ WinGetPosEx(hWnd, & x, & y, & w, & h, & ofl, & oft, & ofr, & ofb)
781
+
782
+ ; -- Loop through each monitor to find which one contains the active window
783
+ Loop MonitorCount
784
+ {
785
+ ; -- Get the dimensions of the current monitor
786
+ MonitorGetWorkArea(A_Index , & l, & t, & r, & b)
787
+
788
+ ; -- Check if the active window is within the current monitor
789
+ if (CheckWindowWithinMonitor(x, y, w, h, ofl, ofr, oft, ofb, r, l, t, b))
790
+ {
791
+ ; -- Calculate the width as half of the monitor
792
+ HalfWidth := Ceil ((r - l) / 2 )
793
+
794
+ ; -- Calculate horizontal position for right aligning
795
+ RightX := (r - ofr) - HalfWidth
796
+
797
+ ; -- Set the window position to start from the middle of the monitor and extend to the very right edge
798
+ WinMove (RightX, t - oft, r - l - HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
799
+
800
+ ; -- Show layout toast
801
+ Toast(" Top Right" , r, l, t, b)
802
+
803
+ ; -- Exit the loop since we found the correct monitor
804
+ break
805
+ }
806
+ }
807
+ }
808
+
809
+ BottomLeft(* )
810
+ {
811
+ ; -- Get the handle of the active window
812
+ hWnd := WinExist (" A" )
813
+ if (hWnd <= 0 )
814
+ return
815
+
816
+ ; -- Get the number of monitors
817
+ MonitorCount := MonitorGetCount()
818
+
819
+ ; -- Get the dimensions of the current window
820
+ WinGetPosEx(hWnd, & x, & y, & w, & h, & ofl, & oft, & ofr, & ofb)
821
+
822
+ ; -- Loop through each monitor to find which one contains the active window
823
+ Loop MonitorCount
824
+ {
825
+ ; -- Get the dimensions of the current monitor
826
+ MonitorGetWorkArea(A_Index , & l, & t, & r, & b)
827
+
828
+ ; -- Check if the active window is within the current monitor
829
+ if (CheckWindowWithinMonitor(x, y, w, h, ofl, ofr, oft, ofb, r, l, t, b))
830
+ {
831
+ ; -- Calculate the width of half of the monitor
832
+ HalfWidth := Ceil ((r - l) / 2 )
833
+
834
+ ; -- Calculate the height of half of the monitor
835
+ HalfHeight := Ceil ((b - t) / 2 )
836
+
837
+ ; -- Set the window position to left one third of monitor and bottom half of it
838
+ WinMove (l - ofl, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
839
+
840
+ ; -- Show layout toast
841
+ Toast(" Bottom Left" , r, l, t, b)
842
+
843
+ ; -- Exit the loop since we found the correct monitor
844
+ break
845
+ }
846
+ }
847
+ }
848
+
849
+ BottomRight(* )
850
+ {
851
+ ; -- Get the handle of the active window
852
+ hWnd := WinExist (" A" )
853
+ if (hWnd <= 0 )
854
+ return
855
+
856
+ ; -- Get the number of monitors
857
+ MonitorCount := MonitorGetCount()
858
+
859
+ ; -- Get the dimensions of the current window
860
+ WinGetPosEx(hWnd, & x, & y, & w, & h, & ofl, & oft, & ofr, & ofb)
861
+
862
+ ; -- Loop through each monitor to find which one contains the active window
863
+ Loop MonitorCount
864
+ {
865
+ ; -- Get the dimensions of the current monitor
866
+ MonitorGetWorkArea(A_Index , & l, & t, & r, & b)
867
+
868
+ ; -- Check if the active window is within the current monitor
869
+ if (CheckWindowWithinMonitor(x, y, w, h, ofl, ofr, oft, ofb, r, l, t, b))
870
+ {
871
+ ; -- Calculate the width as half of the monitor
872
+ HalfWidth := Ceil ((r - l) / 2 )
873
+
874
+ ; -- Calculate horizontal position for right aligning
875
+ RightX := (r - ofr) - HalfWidth
876
+
877
+ ; -- Set the window position to the right half of the monitor and bottom half of it
878
+ WinMove (RightX, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
879
+
880
+ ; -- Show layout toast
881
+ Toast(" Bottom Right" , r, l, t, b)
882
+
883
+ ; -- Exit the loop since we found the correct monitor
884
+ break
885
+ }
886
+ }
887
+ }
888
+
724
889
CheckWindowWithinMonitor(winX, winY, winW, winH, winOffsetLeft, winOffsetRight, winOffsetTop, winOffsetBottom, monRight, monLeft, monTop, monBottom)
725
890
{
726
891
; Calculate the coordinates of the corners of the window
0 commit comments