#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: VADemon | https://twitter.com/BotOfWar Version: 1.0 (first public release) Script Function: Set Fullscreen borderless window style (based on mouse position). #ce ---------------------------------------------------------------------------- #include #include #include #include #include ; http://www.autoitscript.com/forum/topic/82353-dual-monitor-resolution-detection/#entry590685 _GetMonitors() ; Set Monitor List Global $bwBlacklist[5] = ["Progman", "Notepad++", "CabinetWClass", "ExploreWClass", "MozillaWindowClass"] ; Borderless is disabled for these windows Func bw_setWindowBorderless($WindowHandle, $currMon, $xPos = -1, $yPos = -1, $xSize = -1, $ySize = -1) if $xPos == -1 then $xPos = $__MonitorList[$currMon][1] ; these statements to define the default value in the args line only worked in beta. :Sad face: endif if $yPos == -1 then $yPos = $__MonitorList[$currMon][2] endif if $xSize == -1 then $xSize = Abs($__MonitorList[$currMon][1] - $__MonitorList[$currMon][3]) endif if $ySize == -1 then $ySize = Abs($__MonitorList[$currMon][4] - $__MonitorList[$currMon][2]) endif _WinAPI_SetWindowLong($WindowHandle, $GWL_STYLE, BitOR($WS_VISIBLE, $WS_SYSMENU)) ;_WinAPI_ShowWindow($WindowHandle, $WS_MAXIMIZE) ; doesn't work (in beta?) ;WinSetState("[active]", "", @SW_MAXIMIZE) _MaxOnMonitor("[active]") ; Maximize on moniter the mouse's on ;Local $WindowSize = WinGetPos($WindowHandle) _WinAPI_SetWindowPos($WindowHandle, $HWND_TOP, $xPos, $yPos, $xSize, $ySize, $SWP_FRAMECHANGED) EndFunc ;Func bw_preSetWindowBorderless($WindowHandle, $currMon) Func bw_isBlacklisted($WindowHandle) Local $WindowClass = _WinAPI_GetClassName($WindowHandle) For $i = 0 to (UBound($bwBlacklist) - 1) if $bwBlacklist[ $i ] == $WindowClass then return True endif Next return False endfunc Func bw_MoveToMonitor($WindowHandle, $offset = -1) If UBound($__MonitorList) - 1 > 1 Then ; 0 = Total Workspace and 1 = Primary monitor if _WinAPI_GetClassName($WindowHandle) <> "Progman" Then ; Active window is NOT desktop $moveTo = Mod(_GetMonitorFromPoint( WinGetPos($WindowHandle)) + $offset, $__MonitorList[0][0]) ; currMon + offset % monitorCount = move to $moveTo monitor if $moveTo == 0 then if $offset > 0 then $moveTo = $moveTo + 2 else $moveTo = $__MonitorList[0][0] endif endif _CenterOnMonitor($WindowHandle, "", $moveTo) endif endif endFunc ;; Main Global $DLLHandle = DLLOpen("user32.dll") While 1 If _IsPressed("A2", $DLLHandle) and _IsPressed("A3", $DLLHandle) Then ; Left + Right CTRL Local $WindowHandle = WinGetHandle("[active]") ;Local $currMon = _GetMonitorFromPoint() ;MsgBox(0, "Screen size", "Size: " & Abs($__MonitorList[$currMon][1] - $__MonitorList[$currMon][3]) & "x" & Abs($__MonitorList[$currMon][4] - $__MonitorList[$currMon][2]) & @CRLF & "1L: " & $__MonitorList[$currMon][1] & @CRLF & "2T: " & $__MonitorList[$currMon][2] & @CRLF & "3R: " & $__MonitorList[$currMon][3] & @CRLF & "4B: " & $__MonitorList[$currMon][4]) ;Mon x = abs(1-3) ;Mox y = abs(4-2) if _IsPressed("20", $DLLHandle) then ; SPACE if bw_isBlacklisted($WindowHandle) Then SoundPlay( RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\.Default\.Current",""), 0 ) ; Warning else Local $WindowStyle = _WinAPI_GetWindowLong($WindowHandle, $GWL_STYLE) if BitAND($WindowStyle, $WS_THICKFRAME) == 0 then ; if thickframe is not set, that's probably a borderless window _WinAPI_SetWindowLong($WindowHandle, $GWL_STYLE, BitOR($WindowStyle, $WS_CAPTION, $WS_THICKFRAME, $WS_SYSMENU, $WS_TABSTOP, $WS_SIZEBOX, $WS_MINIMIZEBOX)) ; "Restore" default windows window: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx else bw_setWindowBorderless($WindowHandle, _GetMonitorFromPoint()) endif endif elseif _IsPressed("28", $DLLHandle) then ; ARROW DOWN WinSetState($WindowHandle, "", @SW_MINIMIZE) elseif _IsPressed("26", $DLLHandle) then ; ARROW UP Local $WindowState = WinGetState($WindowHandle) If BitAND($WindowState, 32) Then ; is maximized WinSetState($WindowHandle, "", @SW_RESTORE) ; restore to default else WinSetState($WindowHandle, "", @SW_MAXIMIZE) ; else maximize endif elseif _isPressed("25", $DLLHandle) then ; ARROW LEFT bw_MoveToMonitor($WindowHandle, -1) elseif _isPressed("27", $DLLHandle) then ; ARROW RIGHT bw_MoveToMonitor($WindowHandle, 1) endif ; Move windows freely ; Change Window Size sleep(3.5) EndIf if _IsPressed("A3", $DLLHandle) Then ; Right CTRL Local $WindowHandle = WinGetHandle("[active]") if _IsPressed("A1", $DLLHandle) then ; Right Shift WinMove($WindowHandle, "", MouseGetPos(0), MouseGetPos(1)) endif endif sleep(250) Wend