AutoIt 移动窗口

主要是方便两个窗口对比查看

Win + q 窗口移动到左半边
Win + w 窗口移动到右半边
Shift + Win + q 窗口移动到上半边
Shift + Win + w 窗口移动到下半边

* 我的任务栏在屏幕左侧


#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

转载于:https://my.oschina.net/u/234545/blog/130805

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值