AutoIt 移動窗口

主要是方便兩個窗口對比查看 shell

Win + q 窗口移動到左半邊
Win + w 窗口移動到右半邊
Shift + Win + q 窗口移動到上半邊
Shift + Win + w 窗口移動到下半邊 code

* 個人任務欄在屏幕左側 it


#include<array.au3>

Global $g_width = @DesktopWidth, $g_height =@DesktopHeight, $g_taskbar_width = GetTrayWidth()

HotKeySet("#q", "MoveAndResizeToLeft")
HotKeySet("#w", "MoveAndResizeToRight")

HotKeySet("+#q", "MoveAndResizeToTop")
HotKeySet("+#w", "MoveAndResizeToBottom")

;;
;;
While 1
	Sleep(100)
WEnd

;;
;;
Func GetTrayWidth()
	Local $tray = WinGetHandle("[CLASS:Shell_TrayWnd]")
	Local $pos = WinGetPos($tray)
	Local $r = $pos[2] -2
	Return $r
EndFunc

;;
;;
Func MoveAndResizeToLeft()
	Local $t = MyGetActiveWinTitle()	
	WinMove($t,"",$g_taskbar_width,0, ($g_width - $g_taskbar_width)/2, $g_height )	
EndFunc


;;
;;
Func MoveAndResizeToRight()
	Local $t = MyGetActiveWinTitle()	
	WinMove($t,"",($g_width - $g_taskbar_width)/2 + $g_taskbar_width , 0,($g_width - $g_taskbar_width)/2,$g_height )	
EndFunc

;;
;;
Func MoveAndResizeToTop()
	Local $t = MyGetActiveWinTitle()	
	WinMove($t,"",$g_taskbar_width,0, $g_width - $g_taskbar_width, $g_height/2)	
EndFunc


;;
;;
Func MoveAndResizeToBottom()
	Local $t = MyGetActiveWinTitle()	
	WinMove($t,"",$g_taskbar_width, $g_height/2, $g_width-$g_taskbar_width, $g_height/2)	
	
EndFunc


;;
;;
Func MyGetActiveWinTitle()
		Local $list=WinList()
		;_ArrayDisplay($list)
		For $i=1 To $list[0][0]
			If($list[$i][0] <> "" And WinIsActive($list[$i][0])) Then
				Return $list[$i][0]
			EndIf
		Next
		
		Return ""
EndFunc

;;
;;
Func WinIsActive($title)
		If BitAND(WinGetState($title),8) then
			Return 1
		Else
			Return 0
		EndIf
EndFunc
相關文章
相關標籤/搜索