;GridMove ;By jgpaiva ;date: May 2006 ;function: Adjusts windows to a predefined or user-defined desktop grid. ;************************************************************************ini i/o ReadIni: IniVersion = 0 IfExist,%A_AppData%/DonationCoder/GridMove/%A_ScriptName%.ini ScriptDir=%A_AppData%/DonationCoder/GridMove/%A_ScriptName%.ini else IfExist,%A_ScriptDir%\%A_ScriptName%.ini ScriptDir=%A_ScriptDir%\%A_ScriptName%.ini else { ScriptDir=%A_AppData%/DonationCoder/GridMove/%A_ScriptName%.ini } IfExist,%ScriptDir% { IniRead,IniVersion ,%ScriptDir%,IniSettings,IniVersion,1 If IniVersion = 1 { IniWrite,%GridOrder% ,%ScriptDir%,GridSettings,GridOrder IniVersion = 2 IniWrite,%IniVersion% ,%ScriptDir%,IniSettings,Iniversion } If IniVersion = 2 { IniWrite,%UseCommand% ,%ScriptDir%,ProgramSettings,UseCommand IniWrite,%CommandHotkey% ,%ScriptDir%,ProgramSettings,CommandHotkey IniWrite,%UseFastMove% ,%ScriptDir%,ProgramSettings,UseFastMove IniWrite,%FastMoveModifiers%,%ScriptDir%,ProgramSettings,FastMoveModifiers IniVersion = 3 IniWrite, %IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 3 { IniWrite,%TitleLeft% ,%ScriptDir%,ProgramSettings,TitleLeft IniVersion = 4 IniWrite, %IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 4 { IniWrite,%ShowNumbersFlag% ,%ScriptDir%,OtherSettings,ShowNumbersFlag IniVersion = 5 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 5 { IniWrite,%MButtonTimeout% ,%ScriptDir%,InterfaceSettings,MButtonTimeout IniWrite,%Transparency% ,%ScriptDir%,InterfaceSettings,Transparency IniVersion = 6 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 6 { IniWrite,%FastMoveMeta% ,%ScriptDir%,ProgramSettings,FastMoveMeta IniVersion = 7 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 7 { IniWrite,%Exceptions% ,%ScriptDir%,ProgramSettings,Exceptions IniVersion = 8 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 8 { IniWrite,%SafeMode% ,%ScriptDir%,ProgramSettings,SafeMode IniVersion = 9 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 9 { IniWrite,%SequentialMove% ,%ScriptDir%,ProgramSettings,SequentialMove IniVersion = 10 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 10 { IniWrite,%DebugMode% ,%ScriptDir%,ProgramSettings,DebugMode IniVersion = 11 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 11 { IniWrite,%GridOrder% ,%ScriptDir%,GridSettings,GridOrder IniWrite,%GridName% ,%ScriptDir%,GridSettings,GridName IniVersion = 12 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if IniVersion = 12 { IniWrite,%DisableTitleButtonsDetection%,%ScriptDir%,OtherSettings,DisableTitleButtonsDetection IniVersion = 13 IniWrite,%IniVersion% ,%ScriptDir%, IniSettings,Iniversion } if DebugMode Traytip,GridMove,IniVersion is %IniVersion%,10 IniRead,GridName ,%ScriptDir%,GridSettings ,GridName,Error IniRead,LButtonDrag ,%ScriptDir%,InterfaceSettings,LButtonDrag,Error IniRead,MButtonDrag ,%ScriptDir%,InterfaceSettings,MButtonDrag,Error IniRead,EdgeDrag ,%ScriptDir%,InterfaceSettings,EdgeDrag,Error IniRead,EdgeTime ,%ScriptDir%,OtherSettings ,EdgeTime,Error IniRead,ShowGroupsFlag ,%ScriptDir%,OtherSettings ,ShowGroupsFlag,Error IniRead,ShowNumbersFlag ,%ScriptDir%,OtherSettings ,ShowNumbersFlag,Error IniRead,TitleSize ,%ScriptDir%,OtherSettings ,TitleSize,Error IniRead,GridOrder ,%ScriptDir%,GridSettings ,GridOrder,Error IniRead,UseCommand ,%ScriptDir%,Programsettings ,UseCommand,Error IniRead,CommandHotkey ,%ScriptDir%,Programsettings ,CommandHotkey,Error IniRead,UseFastMove ,%ScriptDir%,Programsettings ,UseFastMove,Error IniRead,FastMoveModifiers,%ScriptDir%,Programsettings ,FastMoveModifiers,Error IniRead,FastMoveMeta ,%ScriptDir%,Programsettings ,FastMoveMeta,Error IniRead,TitleLeft ,%ScriptDir%,ProgramSettings ,TitleLeft,Error IniRead,MButtonTimeout ,%ScriptDir%,InterfaceSettings,MButtonTimeout,Error IniRead,Transparency ,%ScriptDir%,InterfaceSettings,Transparency,Error IniRead,Exceptions ,%ScriptDir%,ProgramSettings ,Exceptions,Error IniRead,SafeMode ,%ScriptDir%,ProgramSettings ,SafeMode,Error IniRead,SequentialMove ,%ScriptDir%,ProgramSettings ,SequentialMove,Error IniRead,DebugMode ,%ScriptDir%,ProgramSettings ,DebugMode,Error IniRead,DisableTitleButtonsDetection,%ScriptDir%,OtherSettings ,DisableTitleButtonsDetection,Error If (GridName = "Error" OR LButtonDrag = "Error" OR MButtonDrag = "Error" OR EdgeDrag = "Error" OR EdgeTime = "Error" OR ShowGroupsFlag = "Error" OR TitleSize = "Error" OR ShowGroupsFlag = "Error" OR ShowNumbersFlag = "Error" OR TitleSize = "Error" OR GridOrder = "Error" OR UseCommand = "Error" OR CommandHotkey = "Error" OR UseFastMove = "Error" OR FastMoveModifiers = "Error" OR FastMoveMeta = "Error" OR TitleLeft = "Error" OR MButtonTimeout = "Error" OR Transparency = "Error" OR Exceptions = "Error" OR SafeMode = "Error" OR SequentialMove = "Error" OR DebugMode = "Error" OR DisableTitleButtonsDetection = "Error") { MsgBox,There was an error reading the .ini file.`nThe script will be restarted, and the ini file will be deleted. FileDelete,%ScriptDir% Reload sleep 20000 } } else { if DebugMode Traytip,GridMove,Didn't find ini file`, creating a new one,10 GoSub, AboutHelp GoSub,WriteIni msgbox,64,Information,As this is GridMove's first run`,you'll get some help in the form of tooltips.`nIf you don't like to see them`, just close GridMove through it's tray menu and run it again.`nPlease notice that GridMove may act a bit slower because of these helpers. settimer, helper,100 } return WriteIni: IfNotExist,%ScriptDir% { if DebugMode Traytip,GridMove,Creating ini file,10 FileCreateDir,%A_AppData%/DonationCoder/ if(ErrorLevel <> 0) { ScriptDir=%A_ScriptDir%\%A_ScriptName%.ini } else FileCreateDir,%A_AppData%/DonationCoder/GridMove/ if(ErrorLevel <> 0) { ScriptDir=%A_ScriptDir%\%A_ScriptName%.ini } FileAppend, ,%ScriptDir% if DebugMode Traytip,GridMove,Created ini file: %ScriptDir%,10 } if DebugMode Traytip,GridMove,Writing ini to: %ScriptDir%,10 IniWrite,%GridName% ,%ScriptDir%,GridSettings ,GridName IniWrite,%LButtonDrag% ,%ScriptDir%,InterfaceSettings,LButtonDrag IniWrite,%MButtonDrag% ,%ScriptDir%,InterfaceSettings,MButtonDrag IniWrite,%EdgeDrag% ,%ScriptDir%,InterfaceSettings,EdgeDrag IniWrite,%EdgeTime% ,%ScriptDir%,OtherSettings ,EdgeTime IniWrite,%ShowGroupsFlag% ,%ScriptDir%,OtherSettings ,ShowGroupsFlag IniWrite,%ShowNumbersFlag% ,%ScriptDir%,OtherSettings ,ShowNumbersFlag IniWrite,%TitleSize% ,%ScriptDir%,OtherSettings ,TitleSize IniWrite,%GridOrder% ,%ScriptDir%,GridSettings ,GridOrder IniWrite,%UseCommand% ,%ScriptDir%,ProgramSettings ,UseCommand IniWrite,%CommandHotkey% ,%ScriptDir%,ProgramSettings ,CommandHotkey IniWrite,%UseFastMove% ,%ScriptDir%,ProgramSettings ,UseFastMove IniWrite,%FastMoveModifiers%,%ScriptDir%,ProgramSettings ,FastMoveModifiers IniWrite,%FastMoveMeta% ,%ScriptDir%,ProgramSettings ,FastMoveMeta IniWrite,%SafeMode% ,%ScriptDir%,ProgramSettings ,SafeMode IniWrite,%IniVersion% ,%ScriptDir%,IniSettings ,iniversion IniWrite,%TitleLeft% ,%ScriptDir%,ProgramSettings ,TitleLeft IniWrite,%MButtonTimeout% ,%ScriptDir%,InterfaceSettings,MButtonTimeout IniWrite,%Transparency% ,%ScriptDir%,InterfaceSettings,Transparency IniWrite,%Exceptions% ,%ScriptDir%,ProgramSettings,Exceptions IniWrite,%SequentialMove% ,%ScriptDir%,ProgramSettings,SequentialMove IniWrite,%DebugMode% ,%ScriptDir%,ProgramSettings,DebugMode IniWrite,%DisableTitleButtonsDetection%,%ScriptDir%,OtherSettings,DisableTitleButtonsDetection Return ;***************************************************************About / help GUI AboutHelp: if mutex return mutex:=true gui, 3: Add, Tab, x6 y5 w440 h420, About|Help ;**************About gui, 3: Tab, 1 IfExist %A_ScriptDir%\gridmove.ico gui, 3:Add , Picture, x15 y35,%A_ScriptDir%\gridmove.ico else IfExist %A_ScriptDir%\gridmove.exe gui, 3:Add , Picture, x15 y35,%A_ScriptDir%\gridmove.exe gui, 3:Font,Bold s10 gui, 3:Add ,Text,x65 y45,GridMove V%ScriptVersion% by jgpaiva`n gui, 3:Font, gui, 3:Font, s10 gui, 3:Add ,Text,x15 y95 w420 ,This is a small script that helps you organize your windows in your desktop, by creating a grid that when called up, you can snap windows into. It's bundled with some predefined templates, but you can create your own grids, or download other people's grids. For more information on how to use it, check the help tab or the DonationCoder.com Forum thread. gui, 3:Add ,Text,X15 Y220,It was suggested by Nudone at DonationCoder.com forums, `nin the following thread: gui, 3:Font,CBlue Underline gui, 3:Add ,Text,X15 Y255 GPost,http://www.donationcoder.com/Forums/bb/index.php?topic=3824 gui, 3:Font gui, 3:Font, s10 gui, 3:Add ,Text, y280 X15,`nPlease visit us at: gui, 3:Font,CBlue Underline s10 gui, 3:Add ,Text, y313 X15 GMainSite,http://www.donationcoder.com/ gui, 3:Font IfExist,Images/Cody.png Gui, 3:Add ,Picture, Y290 X280,Images/Cody.png gui, 3:Add ,Button,y350 x15 gdonateAuthor w116 h30,Donate gui, 3:Font, s9 gui, 3:Add ,Text,y400 x15 h10,If you like this program please make a donation to help further development. ;**************HELP gui, 3:Tab, 2 gui, 3:Font, Gui, 3:Add, Edit, w413 R29 vMyEdit ReadOnly IfExist, %A_ScriptDir%\GridMoveHelp.txt FileRead, FileContents,%A_ScriptDir%\GridMoveHelp.txt Else MsgBox,ERROR: GridMoveHelp.txt not found!! GuiControl,3:, MyEdit, %FileContents% /* gui, 3:add, Text, w420, There are 3 methods of interaction with this program, each of them can be disabled or activated through the options menu on the tray menu. gui, 3:add, Text, w420, Method one:`n LButton Drag: When this method is activated, the grid will come up when the user drags`n a window by grabbing its title bar somewhere close to its icon. The number of pixels of `n title bar considered to activate this method is defined in the option "Title Size". gui, 3:add, Text, w420, Method two:`n MButton Drag: When this method is activated, the grid will come up when the user`n presses and holds the middle mouse button and then drags a window. When the user`n releases the middle mouse button, the window is snapped to the highlighted area. gui, 3:add, Text, w420, Method three:`n EdgeDrag: When this method is activated, the grid will come up when the user grabs a`n window and moves the mouse to the edge of the screen. The EdgeTime option defines`n the time the mouse will have to remain in the edge of the screen for the grid to come up. gui, 3:add, Text, w420, The Tray icon's menu contains a Templates submenu. This submenu contains pre-configured grids, and a 'browse' feature, which allows you to use your own customized grids. gui, 3:add, Text, w420, By pressing the windows key and 'g' at the same time`,you get a handy dialog you can use to quickly snap windows. Just press the number of the grid element where you'd like to move the window. gui, 3:add, Text, w420, Check out the forum thread for more information on how to create new grids and how to use additional new functions. */ ;**************OPTIONS ;gui, 3:default ;gui, tab,3 ; ;gui, add, groupbox, ,How to activate GridMove ; ;Gui, add, checkbox, ,By dragging a window by its title ;Gui, add, checkbox, ,By dragging a window while pressing middle mouse button ;Gui, add, checkbox, ,By dragging a window to the edge of the screen ;**************General + complementary functions gui, 3:tab ;gui, 3:Add, Button, g3GuiClose x340 y395 w100 h30, &Ok Gui, 3:show,,GridMove V%ScriptVersion% by jgpaiva return Post: Run,http://www.donationcoder.com/Forums/bb/index.php?topic=3824 GoSub,3GuiCLOSE return MainSite: Run,http://www.donationcoder.com/ GoSub,3Guiclose return DonateSite: Run,http://www.donationcoder.com/Donate/index.html GoSub,3Guiclose 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,3Guiclose return 3GuiEscape: 3GuiClose: buttonok: gui,3:destroy mutex:=false return ;*********************************************************************Templates Template-3part: Menu,Templates,DeleteAll CreateTemplatesMenu() SysGet, MonitorCount, MonitorCount Count := 0 loop, %MonitorCount% { SysGet, Monitor, MonitorWorkArea,%A_index% MonitorWidth := MonitorRight - MonitorLeft MonitorHeight := MonitorBottom - MonitorTop Count+=1 %Count%TriggerTop := MonitorTop %Count%TriggerRight := MonitorRight %Count%TriggerBottom := MonitorBottom %Count%TriggerLeft := MonitorLeft + Round(MonitorWidth / 3) %Count%GridTop := %Count%TriggerTop %Count%GridRight := %Count%TriggerRight %Count%GridBottom := %Count%TriggerBottom %Count%GridLeft := %Count%TriggerLeft Count+=1 %Count%TriggerTop := MonitorTop %Count%TriggerRight := MonitorLeft + Round(MonitorWidth / 3) %Count%TriggerBottom := MonitorTop + Round(MonitorHeight / 2) %Count%TriggerLeft := MonitorLeft %Count%GridTop := %Count%TriggerTop %Count%GridRight := %Count%TriggerRight %Count%GridBottom := %Count%TriggerBottom %Count%GridLeft := %Count%TriggerLeft Count+=1 temp := count - 1 %Count%TriggerTop := %Temp%TriggerBottom +0.01 %Count%TriggerRight := MonitorLeft + Round(MonitorWidth / 3) %Count%TriggerBottom := MonitorBottom %Count%TriggerLeft := MonitorLeft %Count%GridTop := %Count%TriggerTop %Count%GridRight := %Count%TriggerRight %Count%GridBottom := %Count%TriggerBottom %Count%GridLeft := %Count%TriggerLeft } NGroups := MonitorCount * 3 Gui,Destroy GoSub, CreateGroups GridName = 3Part GoSub, WriteIni return