; ; ScriptName: DesktopScroll ; Author: jgpaiva ; ; Script Function: ; Create a giant desktop ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #persistent #maxthreadsperhotkey,1 #singleinstance,force #InstallMouseHook SendMode Input ; Recommended for new scripts due to its superior speed and reliability. CoordMode,Mouse,Screen SetWinDelay, 0 Sysget,Monitor,MonitorWorkArea MonitorWidth := MonitorRight-MonitorLeft MonitorHeight := MonitorBottom-MonitorTop MaxHorizontalScroll := MonitorWidth/2 MaxVerticalScroll := MonitorHeight/2 Multiplier := 2 ;-------------------------------------------------- ; JumpSize := 2000 ;-------------------------------------------------- Exceptions = QuarkXPress,Shell_TrayWnd,Progman,DV2ControlHost CurrentHPos := MaxHorizontalScroll CurrentVPos := MaxVerticalScroll InLoop := false Moving := false MoveWindowUnderMouse := True KeyToWait = LButton Settimer,KeepWindowOnScreen,100 return Lwin & RButton:: MoveWindowUnderMouse := false KeyToWait = RButton LWin & LButton:: if(Moving) return Moving := true MouseGetPos,MouseX,MouseY,MouseWin InitialHpos := CurrentHPos InitialVpos := CurrentVPos Loop { OldMouseX := MouseX OldMouseY := MouseY sleep,50 GetKeyState, State, %KeyToWait%, P if(state = "U") { WinActivate,Program Manager Moving := false MoveWindowUnderMouse := true KeyToWait = LButton return } MouseGetPos,MouseX,MouseY if(MouseX <> OldMouseX OR MouseY <> OldMouseY) MoveScreen(Multiplier*(MouseX - OldMouseX) ,Multiplier*(MouseY - OldMouseY),MoveWindowUnderMouse) ;-------------------------------------------------- ; Jump ;-------------------------------------------------- ;-------------------------------------------------- ; if(CurrentHPos > InitialHPos + JumpSize) ; { ; MoveScreen(MonitorWidth - CurrentHPos + InitialHPos,0) ; InitialHpos := CurrentHPos ; } ; if(CurrentHPos < InitialHPos - JumpSize) ; { ; MoveScreen(-MonitorWidth + CurrentHPos - InitialHPos,0) ; InitialHpos := CurrentHPos ; } ; if(CurrentVPos > InitialVPos + JumpSize) ; { ; MoveScreen(0,MonitorHeight - CurrentVPos + InitialVPos) ; InitialVpos := CurrentVPos ; } ; if(CurrentVPos < InitialVPos - JumpSize) ; { ; MoveScreen(0,-MonitorHeight + CurrentVPos - InitialVPos) ; InitialVpos := CurrentVPos ; } ;-------------------------------------------------- } return MoveScreen(Xincrease,Yincrease,MoveWindowUnderMouse) { global Exceptions global CurrentHPos global CurrentVPos global MaxHorizontalScroll global MaxVerticalScroll global MouseWin Winget,WindowList,List NewHPos := CurrentHPos + Xincrease NewVPos := CurrentVPos + Yincrease if(NewHPos > MaxHorizontalScroll) { Xincrease := MaxHorizontalScroll - CurrentHPos NewHPos := MaxHorizontalScroll } if(NewHPos < - MaxHorizontalScroll) { Xincrease := - MaxHorizontalScroll - CurrentHPos NewHPos := - MaxHorizontalScroll } if(NewVPos > MaxVerticalScroll) { Yincrease := MaxVerticalScroll - CurrentVPos NewVPos := MaxVerticalScroll } if(NewVPos < - MaxVerticalScroll) { Yincrease := - MaxVerticalScroll - CurrentVPos NewVPos := - MaxVerticalScroll } CurrentHPos := NewHPos CurrentVPos := NewVPos Loop,%windowlist% { CurrentWindowId := WindowList%A_index% if(!MoveWindowUnderMouse) if(CurrentWindowId = MouseWin) continue WingetClass,CurrentWindowClass,ahk_id %CurrentWindowId% if Exceptions contains %CurrentWindowClass% continue WinGetPos,CurrentWindowX,CurrentWindowY ,CurrentWindowHeight,CurrentWindowWidth,ahk_id %CurrentWindowId% NewX := CurrentWindowX + Xincrease NewY := CurrentWindowY + Yincrease WinMove,ahk_id %CurrentWindowId%, ,NewX ,NewY } } KeepWindowOnScreen: If(Moving) return WingetClass,ActiveWindowClass,A Winget,ActiveWindowState,MinMax,A WinGet,ActiveWindowId,id,A CoordMode,Mouse,Relative MouseGetPos,MouseX,MouseY WinGetPos,WindowX,WindowY,ActiveWindowWidth,ActiveWindowHeight,A if Exceptions contains %ActiveWindowClass% return if(ActiveWindowId = OldActiveWindowId) return If((MouseY < 20 AND MouseY >= 0) OR (MouseX <= 3 AND MouseX >= 0) OR (MouseX >= ActiveWindowWidth - 4 AND MouseX < ActiveWindowWidth) OR (MouseY >= ActiveWindowHeight - 4 AND MouseY < ActiveWindowHeight)) { Moving := true Keywait,LButton,P Moving := false return } OldActiveWindowId := ActiveWindowId if(ActiveWindowState <> 0) return if(ActiveWindowWidth <= MonitorWidth) if(WindowX + ActiveWindowWidth > MonitorLeft + MonitorWidth) MoveScreen(MonitorLeft + MonitorWidth - WindowX - ActiveWindowWidth ,0,true) WinGetPos,WindowX,WindowY,ActiveWindowWidth,ActiveWindowHeight,A if(ActiveWindowHeight <= MonitorHeight) if(WindowY + ActiveWindowHeight > MonitorTop + MonitorHeight) MoveScreen(0,MonitorTop + MonitorHeight - Windowy - ActiveWindowHeight ,true) WinGetPos,WindowX,WindowY,ActiveWindowWidth,ActiveWindowHeight,A if(WindowX < MonitorLeft) MoveScreen(MonitorLeft - WindowX,0,true) WinGetPos,WindowX,WindowY,ActiveWindowWidth,ActiveWindowHeight,A if(WindowY < MonitorTop) MoveScreen(0,MonitorTop - WindowY,true) return