Dock application & restrict desktop to remaining area?

Get help with using AutoHotkey and its commands and hotkeys
q1w2e3r4t7
Posts: 2
Joined: 10 Jul 2019, 08:36

Dock application & restrict desktop to remaining area?

10 Jul 2019, 09:10

Looking to dock an application (Word, Excel or Notpad) to the right 5cm's of my screen to allow me to access the program at any stage / make notes at any time, and restrict other programs maximise & docking to the remaining area.
I love to use windows snap (windows + left / right), would love if this still works within the remaining area not used by docked application.

So like the way the taskbar is docked to the bottom of windows 10, always accessable and the desktop forms the remaining area. In addition to this, i would like to dock a program to the side of the screen, further restricting the desktop to the remaining area.

I have the always on top AHK code, however can't figure the restricting desktop.

Tried searching google & AHK, however no luck.

Any help appreciated.
q1w2e3r4t7
Posts: 2
Joined: 10 Jul 2019, 08:36

Re: Dock application & restrict desktop to remaining area?

19 Jul 2019, 04:02

I've mostly managed to pull together and get a script working
Posting to share and get review / feed back.

This;
1. restricts desktop working area.
2. keeps ms access ontop and positioned to the right , docked
3. if minimised (ie. CTRL+M) brings Access back up to docked position.


Love any feedback.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


;=======================================
;  SET WORKING AREA
;=======================================

x := 350
h := 0
WinGetPos,,,,h, ahk_class Shell_TrayWnd

;Gui, +AlwaysOnTop -Caption

;VarSetCapacity( old_area, 16 )

; SPI_GETWORKAREA
success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &old_area, "uint", 0 )

VarSetCapacity( area, 16, 0 )

EncodeInteger( A_ScreenWidth-x, 4, &area, 8 )
EncodeInteger( A_ScreenHeight-h, 4, &area, 12 )

; SPI_SETWORKAREA
success := DllCall( "SystemParametersInfo", "uint", 0x2F, "uint", 0, "uint", &area, "uint", 0 )
if ( ErrorLevel or ! success )
{
	MsgBox, [1] failed: EL = %ErrorLevel%
	ExitApp
}


;=======================================
;  OPEN ACCESS & SET POSITION
;=======================================

WinActivate, Access ; 
Winset, Alwaysontop, , A
AccessWin := A
WinMove a,, A_ScreenWidth - x, 0, x, A_ScreenHeight - h ; POSITION ACTIVE WINDOW (ACCESS)


;=======================================
;  ENSURE ACCESS VISIBLE
;=======================================

WinMove AccessWin, , A_ScreenWidth - x, 0, x, A_ScreenHeight - h ; POSITION ACTIVE WINDOW (ACCESS)


;=======================================
;  ENSURE ACCESS VISIBLE
;=======================================

Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam ) {
	If (wParam = 5)  ;HSHELL_GETMINRECT
	{            
		hwnd := NumGet( lParam+0 ) 
		WinGetTitle, Title, ahk_id %hwnd%
		WinGet, status,MinMax,ahk_id %hwnd%

		abc := % substr(Title,1,6)
		if (abc = "Access") 
		{
			if (status<>0)
			{
				WinActivate, ahk_id %hwnd%
;				WinMove, ahk_id %hwnd%, , 0, 0
				WinMove, ahk_id %hwnd%, , A_ScreenWidth - 350, 0, 350, A_ScreenHeight - h
			  }
	          }
	}
}
ExitApp

EncodeInteger( p_value, p_size, p_address, p_offset )
{
	loop, %p_size%
		DllCall( "RtlFillMemory"
			, "uint", p_address+p_offset+A_Index-1
			, "uint", 1
			, "uchar", ( p_value >> ( 8*( A_Index-1 ) ) ) & 0xFF )
}
Justgogoal
Posts: 1
Joined: 12 Feb 2020, 15:32

Re: Dock application & restrict desktop to remaining area?

15 Feb 2020, 07:20

Thanks Sir Everyone Here.
I get the best help from what you haved write. :)

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 334 guests