;DialogMove ;By jgpaiva ;date: April 2006 ;function: moves windows smaller than a given size to a place closer to the mouse position. ScriptVersion=2.0 #persistent #SingleInstance,Force mutex:=false LastWindowActive= PredefWinHeight:=400 PredefWinWidth:=400 PredefWinWidth2:=A_ScreenWidth PredefWinHeight2:=140 ScreenTop:=A_ScreenHeight ScreenRight:=A_ScreenWidth ScreenBottom:=30 ScreenLeft:=0 WinBorder:= 30 UseHotkey:=true DetectableWindows= NotDetectableWindows= UseBuffer:=true MoveToControl:=true hotkey1=F8 hotkey2=F9 hotkey3=F10 hotkey4=F11 Hotkey1Function=MakeDetectableTitle hotkey2Function=MakeNotDetectable hotkey3Function=MakeDetectable hotkey4Function=MakeNotDetectableTitle ButtonsList=Ok,Save,Guardar Menu,Tray,Add,About/Options,options, Menu,Tray,Add,Options,Options Menu,Tray,Add,Reload,Reload Menu,Tray,Add,Exit,ExitProgram Menu,Tray,NoStandard Menu,Tray,Default,About/options Menu,Tray,Icon,%SystemRoot%\system32\SHELL32.dll,25 Menu,Tray,Click,1 Menu,Tray,Tip,DialogMove v%ScriptVersion% GoSub,ReadIni GetMonitorSizes() SetWinDelay, -1 DetectHiddenWindows,off If UseHotkey gosub,SetHotkeys WinGet, id, list,,, Program Manager Settimer,FindWindow,40 return FindWindow: ActiveWindow := WinActive("A") If ActiveWindow = %LastWindowActive% return LastWindowActive := ActiveWindow If UseBuffer { loop,%id% { StringTrimRight, this_id, id%a_index%, 0 If This_Id=%ActiveWindow% return } WinGet, id, list,,, Program Manager } SetBatchLines,-1 WinGetPos,WinX,WinY, WinWidth, WinHeight,ahk_id %ActiveWindow% if WinWidth = return WinGetClass,WinClass WinGetTitle,WinTitle,ahk_id %ActiveWindow% WinClass=ahk_class%A_space%%Winclass% If WinTitle="" return If NotDetectableWindow(WinTitle,WinClass) return If DetectableWindow(WinTitle,WinClass) gosub movewindow If WinHeight < %PredefWinHeight% If WinWidth < %PredefWinWidth% gosub,MoveWindow If WinHeight < %PredefWinHeight2% If WinWidth < %PredefWinWidth2% gosub,MoveWindow return movewindow: CoordMode,Mouse,Screen MouseGetPos, MouseX, MouseY, MouseWin, current = null loop,%MonitorCount% { if(MouseX < MonitorReal%A_Index%Right) if(MouseX >= MonitorReal%A_Index%Left) if(MouseY < MonitorReal%A_Index%Bottom) if(MouseY >= MonitorReal%A_Index%Top) currentMonitor:=A_Index } FinalWinX := Monitor%currentMonitor%Left + Monitor%CurrentMonitor%Width/2 - winWidth/2 FinalWinY := Monitor%currentMonitor%Top + Monitor%CurrentMonitor%Height/2 - winHeight/2 WinMove, FinalWinX , FinalWinY return DetectableWindow(WinTitle,WinClass) { Global DetectableWindows If WinClass = Return false If DetectableWindows = return false If WinTitle contains %DetectableWindows% return true IfInString,DetectableWindows,%WinClass% return true return false } NotDetectableWindow(WinTitle,Winclass) { Global NotDetectableWindows If NotDetectableWindows = return false If WinTitle contains %NotDetectableWindows% return true IfInString,NotDetectableWindows,%WinClass% return true return false } MakeNotDetectable: ActiveWindow := WinActive("A") WinGetClass,WinClass NotDetectableWindows=ahk_class %WinClass%,%NotDetectableWindows% GoSub,WriteIni return MakeNotDetectableTitle: ActiveWindow := WinActive("A") WinGetTitle,WinTitle NotDetectableWindows=%WinTitle%,%NotDetectableWindows% GoSub,WriteIni return MakeDetectableTitle: ActiveWindow := WinActive("A") WinGetTitle,WinTitle DetectableWindows=%WinTitle%,%DetectableWindows% GoSub,WriteIni return MakeDetectable: ActiveWindow := WinActive("A") WinGetClass,WinClass DetectableWindows=ahk_class %WinClass%,%DetectableWindows% GoSub,WriteIni return ;************************************************************************ini i/o ReadIni: IniVersion = 3 IfExist,%A_ScriptName%.ini { IniRead, IniVersion ,%A_ScriptName%.ini,IniSettings,IniVersion,1 If IniVersion = 1 { IniWrite,%MoveToControl% ,%A_ScriptName%.ini,Settings,MoveToControl IniVersion = 2 } If IniVersion = 2 { IniWrite,%ButtonsList% ,%A_ScriptName%.ini,Settings,ButtonsList IniVersion = 3 } IniWrite,%IniVersion% ,%A_ScriptName%.ini,IniSettings,Iniversion IniRead,MoveToControl ,%A_ScriptName%.ini,Settings,MoveToControl,%MoveToControl% IniRead,PredefWinHeight ,%A_ScriptName%.ini,Settings,PredefWinHeight,%PredefWinHeight% IniRead,PredefWinWidth ,%A_ScriptName%.ini,Settings,PredefWinWidth,%PredefWinWidth% IniRead,UseHotkey ,%A_ScriptName%.ini,Settings,UseHotkey,%UseHotkey% IniRead,DetectableWindows ,%A_ScriptName%.ini,Settings,DetectableWindows,%DetectableWindows% IniRead,NotDetectableWindows ,%A_ScriptName%.ini,Settings,NotDetectableWindows,%NotDetectableWindows% IniRead,UseBuffer ,%A_ScriptName%.ini,Settings,UseBuffer,%UseBuffer% IniRead,WinBorder ,%A_ScriptName%.ini,Settings,WinBorder,%WinBorder% IniRead,Screenright ,%A_ScriptName%.ini,Settings,Screenright,%Screenright% IniRead,Screentop ,%A_ScriptName%.ini,Settings,Screentop,%Screentop% IniRead,Screenleft ,%A_ScriptName%.ini,Settings,Screenleft,%Screenleft% IniRead,ScreenBottom ,%A_ScriptName%.ini,Settings,ScreenBottom,%ScreenBottom% IniRead,hotkey1 ,%A_ScriptName%.ini,Settings,hotkey1,%hotkey1% IniRead,hotkey1function ,%A_ScriptName%.ini,Settings,hotkey1function,%hotkey1function% IniRead,hotkey2 ,%A_ScriptName%.ini,Settings,hotkey2,%hotkey2% IniRead,hotkey2function ,%A_ScriptName%.ini,Settings,hotkey2function,%hotkey2function% IniRead,hotkey3 ,%A_ScriptName%.ini,Settings,hotkey3,%hotkey3function% IniRead,hotkey3function ,%A_ScriptName%.ini,Settings,hotkey3function,%hotkey3function% IniRead,hotkey4 ,%A_ScriptName%.ini,Settings,hotkey4,%hotkey4function% IniRead,hotkey4function ,%A_ScriptName%.ini,Settings,hotkey4function,%hotkey4function% IniRead,PredefWinWidth2 ,%A_ScriptName%.ini,Settings,PredefWinWidth2,%PredefWinWidth2% IniRead,PredefWinHeight2 ,%A_ScriptName%.ini,Settings,PredefWinHeight2,%PredefWinHeight2% IniRead,ButtonsList ,%A_ScriptName%.ini,Settings,ButtonsList,%ButtonsList% } else GoSub,WriteIni return WriteIni: IfNotExist,%A_ScriptName%.ini FileAppend,%A_ScriptName%, IniWrite,%PredefWinHeight% ,%A_ScriptName%.ini,Settings,PredefWinHeight IniWrite,%PredefWinWidth% ,%A_ScriptName%.ini,Settings,PredefWinWidth IniWrite,%PredefWinWidth2% ,%A_ScriptName%.ini,Settings,PredefWinWidth2 IniWrite,%PredefWinHeight2% ,%A_ScriptName%.ini,Settings,PredefWinHeight2 IniWrite,%UseHotkey% ,%A_ScriptName%.ini,Settings,UseHotkey IniWrite,%DetectableWindows% ,%A_ScriptName%.ini,Settings,DetectableWindows IniWrite,%NotDetectableWindows% ,%A_ScriptName%.ini,Settings,NotDetectableWindows IniWrite,%UseBuffer% ,%A_ScriptName%.ini,Settings,UseBuffer IniWrite,%WinBorder% ,%A_ScriptName%.ini,Settings,WinBorder IniWrite,%ScreenRight% ,%A_ScriptName%.ini,Settings,ScreenRight IniWrite,%ScreenLeft% ,%A_ScriptName%.ini,Settings,ScreenLeft IniWrite,%ScreenTop% ,%A_ScriptName%.ini,Settings,ScreenTop IniWrite,%ScreenBottom% ,%A_ScriptName%.ini,Settings,ScreenBottom IniWrite,%hotkey1% ,%A_ScriptName%.ini,Settings,hotkey1 IniWrite,%hotkey1function% ,%A_ScriptName%.ini,Settings,hotkey1function IniWrite,%hotkey2% ,%A_ScriptName%.ini,Settings,hotkey2 IniWrite,%hotkey2function% ,%A_ScriptName%.ini,Settings,hotkey2function IniWrite,%hotkey3% ,%A_ScriptName%.ini,Settings,hotkey3 IniWrite,%hotkey3function% ,%A_ScriptName%.ini,Settings,hotkey3function IniWrite,%hotkey4% ,%A_ScriptName%.ini,Settings,hotkey4 IniWrite,%hotkey4function% ,%A_ScriptName%.ini,Settings,hotkey4function IniWrite,%IniVersion% ,%A_ScriptName%.ini,IniSettings,Iniversion IniWrite,%MoveToControl% ,%A_ScriptName%.ini,Settings,MoveToControl IniWrite,%ButtonsList% ,%A_ScriptName%.ini,Settings,ButtonsList Return ;****************************************************************************Gui options: if mutex return mutex:=true Gui, Add, Tab, x6 y5 w460 h380, Windows|Rules|Hotkeys|About Gui, Tab, 1 Gui, Add, Text, x16 y35 w300 h20, Which windows should I move? Gui, Add, Edit, x16 y55 w440 h120 vDetectableWindows, %DetectableWindows% Gui, Add, Text, x16 y195 w300 h20 , Which windows can't I move? Gui, Add, Edit,Section x16 y215 w440 h120 vNotDetectableWindows, %NotDetectableWindows% Gui, Add, Checkbox,Section xs w230 h30 Checked%usebuffer% vusebuffer, Use the window buffer? Gui, Add, Checkbox,ys+7 Checked%MoveToControl% vMoveToControl,Move window to active control? Gui, Tab, 2 Gui, Add, Text, x16 y45 w160 h16,Move every window that has: Gui, Add, Text, x15 y72 w50 h16,( Width < Gui, Add, Edit, x60 y70 w30 h16 Number vPredefWinWidth,%PredefWinWidth% Gui, Add, Text, x92 y72 w70 h16,AND Heigth < Gui, Add, Edit, x162 y70 w30 h16 Number vPredefWinHeight,%PredefWinHeight% Gui, Add, Text, x195 y72, ) OR Gui, Add, Text, x235 y72 w50 h16,( Width < Gui, Add, Edit, x280 y70 w30 h16 Number vPredefWinWidth2,%PredefWinWidth2% Gui, Add, Text, x312 y72 w70 h16,AND Heigth < Gui, Add, Edit, x382 y70 w30 h16 Number vPredefWinHeight2,%PredefWinHeight2% Gui, Add, Text, x415 y72, ) Gui, Add, Text, x16 y120 ,List of buttons to look for with Move To Control active: Gui, Add, Edit, w300 vButtonsList, %ButtonsList% ;Gui, Add, Text, x16 y75 w160 h20, Width of the detectable dialogs: ;Gui, Add, Edit, x176 y75 w60 h20 Number vPredefWinWidth,%PredefWinWidth% ;Gui, Add, Text, x176 y117 w70 h20 +Center, Screen Top ;Gui, Add, Edit, x176 y135 w70 h20 Number vScreenTop,%Screentop% ; ;Gui, Add, Text, x106 y147 w70 h20 +Center, Screen Left ;Gui, Add, Edit, x106 y165 w70 h20 Number vScreenLeft,%ScreenLeft% ; ;Gui, Add, Text, x246 y147 w70 h20 +Center, Screen Right ;Gui, Add, Edit, x246 y165 w70 h20 Number vScreenRight,%ScreenRight% ; ;Gui, Add, Text, x176 y187 w70 h20 +Center,Screen Bottom ;Gui, Add, Edit, x176 y205 w70 h20 Number vScreenBottom,%ScreenBottom% ; ; ;Gui, Add, Text, x16 y260 w160 h20, Size of the border of the window: ;Gui, Add, Edit, x176 y260 w60 h20 Number vWinBorder,%WinBorder% ;Gui, Add, Checkbox, x16 y345 w260 h30 Checked%usehotkey% vusehotkey, Would you like the hotkeys to be on? Gui, Tab, 3 Gui, Add, Text, x16 y35 w300 h30, In this tab, you can setup the options for the hotkeys. `nJust type an hotkey and an action for it. Gui, Add, Checkbox, x16 y80 w260 h30 Checked%usehotkey% vusehotkey, Would you like the hotkeys to be on? Gui, Add, GroupBox,x12 y120 w58 h148,Hotkeys Gui, Add, GroupBox,x76 y120 w158 h148,Actions ;Gui, Add, Text, X16 Y120 W50 h20, Hotkey ;Gui, Add, Text, X80 Y120 W50 h20, Action Gui, Add, Edit, X16 y150 w50 h20 vhotkey1,%hotkey1% Gui, Add, Edit, X80 y150 w150 h20 vhotkey1function,%hotkey1function% Gui, Add, Edit, X16 y180 w50 h20 vhotkey2,%hotkey2% Gui, Add, Edit, X80 y180 w150 h20 vhotkey2function,%hotkey2function% Gui, Add, Edit, X16 y210 w50 h20 vhotkey3,%hotkey3% Gui, Add, Edit, X80 y210 w150 h20 vhotkey3function,%hotkey3function% Gui, Add, Edit, X16 y240 w50 h20 vhotkey4,%hotkey4% Gui, Add, Edit, X80 y240 w150 h20 vhotkey4function,%hotkey4function% Gui, Tab, 4 Gui, Add, Picture, x15 y35 Icon25,%SystemRoot%\system32\SHELL32.dll Gui,Font,Bold Gui,Add,Text,x60 y45,DialogMove V%ScriptVersion% by jgpaiva`n Gui,Font Gui,Add,Text,x15 y80 w420 ,This is a small script that moves small dialog windows to the mouse position, as soon as they are created. It's highly costumizable, for more informations on how it works, please see it's topic at donationcoder.com forums. Gui, Add,Text,,It was suggested by Nudone at DonationCoder.com forums, in the following thread: Gui,Font,CBlue Underline Gui,Add,Text, GPost,http://www.donationcoder.com/Forums/bb/index.php?topic=3097 Gui,Font Gui,Add,Text,,Please visit us at: Gui,Font,CBlue Underline Gui,Add,Text, GMainSite,http://www.donationcoder.com/ Gui,Font Gui,Add,Text,,`nIf you like this program, please contribute to DonationCoder.com. Gui,Add, Button,xm y270 gdonatesite w160 h30,&Donate To DonationCoder.com Gui,Add, Button,xm+170 y270 gdonateAuthor w116 h30,Donate To The &Author Gui,tab Gui, Add, Button, gGuiClose x366 y395 w100 h30, &Cancel Gui, Add, Button, gbuttonOk x256 y395 w100 h30 default, &OK Gui, Show,, DialogMove Return Post: Run,http://www.donationcoder.com/Forums/bb/index.php?topic=3097 GoSub,GuiCLOSE return MainSite: Run,http://www.donationcoder.com/ GoSub,GuiCLOSE return DonateSite: Run,http://www.donationcoder.com/Donate/index.html GoSub,GuiCLOSE return DonateAuthor: Run,https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=jgpaiva`%40gmail`%2ecom&item_name`=donate`%20to`%20jgpaiva&item_number`=donationcoder`%2ecom&no_shipping=1&cn=Please`%20drop`%20me`%20a`%20line`%20`%3aD&tax`=0¤cy_code=EUR&bn=PP`%2dDonationsBF&charset=UTF`%2d8 GoSub,GuiCLOSE return GuiEscape: GuiClose: gui,destroy mutex:=false return buttonok: Gui,submit gui,destroy mutex:=false GoSub,WriteIni reload return reload: reload ExitProgram: gosub,writeini exitapp SetHotkeys: if hotkey1 <> if hotkey1function <> Hotkey,%hotkey1%,%hotkey1function% if hotkey2 <> if hotkey2function <> Hotkey,%hotkey2%,%hotkey2function% if hotkey3 <> if hotkey3function <> Hotkey,%hotkey3%,%hotkey3function% if hotkey4 <> if hotkey4function <> Hotkey,%hotkey4%,%hotkey4function% return GetMonitorSizes() { Global Sysget,MonitorCount,MonitorCount Loop,%MonitorCount% { SysGet,MonitorReal,Monitor,%A_Index% SysGet,Monitor,MonitorWorkArea,%A_Index% Monitor%A_Index%Left :=MonitorLeft Monitor%A_Index%Bottom :=MonitorBottom Monitor%A_Index%Right :=MonitorRight Monitor%A_Index%Top :=MonitorTop Monitor%A_Index%Width :=MonitorRight - MonitorLeft Monitor%A_Index%Height :=MonitorBottom - MonitorTop MonitorReal%A_Index%Left :=MonitorRealLeft MonitorReal%A_Index%Bottom :=MonitorRealBottom MonitorReal%A_Index%Right :=MonitorRealRight MonitorReal%A_Index%Top :=MonitorRealTop MonitorReal%A_Index%Width :=MonitorRealRight - MonitorRealLeft MonitorReal%A_Index%Height :=MonitorRealBottom - MonitorRealTop } return }