Created
October 28, 2016 07:58
-
-
Save neuronix/3de18357db242ec711b5838c06b6f5db to your computer and use it in GitHub Desktop.
AutoIt script to position window by name (will position Flash Player window by default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; AutoIt script to position window by name (will position Flash Player window by default). | |
; Useful while working on flash projects with FlashDevelop for example, to position the debug window in the same position every launch. | |
; PositionWindow.exe <title> <mode> <x> <y> <interval> | |
; title: string to search in window title. Default is "Adobe Flash Player" | |
; mode: possible values. Default is "loop" | |
; - loop: will reposition every <interval> milliseconds | |
; - wait: will poll every <interval>ms until window appears then positions it once | |
; - once: just positions the window on execution | |
; x/y: pixels value or center. Defaults are 0 | |
; interval: polling value in milliseconds. Default is 500 | |
; | |
; Example: PositionWindow.exe VLC loop center center 2000 | |
Func MoveFP($x, $y, $search) | |
Local $aList = WinList() | |
For $i = 1 To $aList[0][0] | |
If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then | |
Local $title = $aList[$i][0] | |
If (StringInStr($title, $search)) Then | |
Local $size = WinGetClientSize($title) | |
If ($x == "center") Then | |
$x = (@DesktopWidth - $size[0]) / 2 | |
EndIf | |
If ($y == "center") Then | |
$y = (@DesktopHeight - $size[1]) / 2 | |
EndIf | |
WinMove($title, "", $x, $y) | |
Return True | |
EndIf | |
EndIf | |
Next | |
return False | |
EndFunc | |
Local $search = "Adobe Flash Player" | |
Local $mode = "loop" | |
Local $x = 0 | |
Local $y = 0 | |
Local $interval = 500 | |
If $CmdLine[0] >= 1 Then | |
$search = $CmdLine[1] | |
If $CmdLine[0] >= 2 Then | |
$mode = $CmdLine[2] | |
EndIf | |
If $CmdLine[0] >= 4 Then | |
$x = $CmdLine[3] | |
$y = $CmdLine[4] | |
EndIf | |
If $CmdLine[0] >= 5 Then | |
$interval = $CmdLine[5] | |
EndIf | |
EndIf | |
If $mode == "loop" Then | |
While 1 | |
MoveFP($x, $y, $search) | |
Sleep($interval) | |
WEnd | |
ElseIf $mode == "wait" Then | |
While Not MoveFP($x, $y, $search) | |
Sleep($interval) | |
WEnd | |
Else | |
MoveFP($x, $y, $search) | |
EndIf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment