1 (изменено: john_dease, 2023-01-18 16:08:38)

Тема: AHK: Запуск окна с перемещением

Добрый день! В самом низу приведен скрипт, который производит перемещение окон влево или вправо по клавишам "Alt+[" и "Alt+]".

Также на горячую клавишу "1" добавлен код, который запускает окно с диском "C:\" и разворачивает его слева экрана:

1::
Run Explorer.exe /n`,"C:\",,,WID 

WinWait, ahk_class CabinetWClass, , 3
if ErrorLevel
   return
WinWaitActive, ahk_class CabinetWClass
WinActivate, ahk_class CabinetWClass

gosub, LftHlfSub
return

Возник вопрос - как на AHK запускать это окно сразу в развернутом слева состоянии?

; Move and Resize Active Window to LEFT HALF of Current Monitor
![::
LftHlfSub:
{
	; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
	GoSub, ExcludPrgrm
	If (IgnorePrgrm == True)
	{
		Return
	}

	; Retrieve Coordinates, Dimensions, Min/Max State, Process Name and Title of Active Window
	WinGetPos, WinLft, WinTop, WinWdt, WinHgt, A
	WinGet, WinMMax, MinMax, A
	WinGet, PNameHlfLft, ProcessName, A
	WinGetTitle, TNameHlfLft, A

	; Add Correction Factor per Program + Find in which Monitor Active Window is located
	WinGet, PNameWin, ProcessName, A
	{
		HrzCrctn = -14
		HgtCrctn = 8
		WdtCrctn = 30
	}
	; Retrieves on which Monitor Number the Active Window is on
	GoSub, WinCurntMon

	; If Window is Maximized, "UnMaximize" it
	;!!If (WinMMax == 1)
	{
		WinRestore, A
	}
	; Move and Resize Active Window to Left Half of Current Monitor
	WinMove, A, , MonLft[OnMonitor] + HrzCrctn, MonTop[OnMonitor], MonHlfWdt[OnMonitor] + WdtCrctn, MonHgt[OnMonitor] + HgtCrctn
	Return
}





; Move and Resize Active Window to RIGHT HALF of Current Monitor
!]::
RgtHlfSub:
{
	; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
	GoSub, ExcludPrgrm
	If (IgnorePrgrm == True)
	{
		Return
	}

	; Retrieve Coordinates, Dimensions, Min/Max State, Process Name and Title of Active Window
	WinGetPos, WinLft, WinTop, WinWdt, WinHgt, A
	WinGet, WinMMax, MinMax, A
	WinGet, PNameHlfLft, ProcessName, A
	WinGetTitle, TNameHlfLft, A

	; Add Correction Factor per Program + Find in which Monitor Active Window is located
	WinGet, PNameWin, ProcessName, A
	{
		HrzCrctn = 2
		HgtCrctn = 8
		WdtCrctn = 10
	}
	; Retrieves on which Monitor Number the Active Window is on
	GoSub, WinCurntMon

	; If Window is Maximized, "UnMaximize" it
	;!!If (WinMMax == 1)
	{
		WinRestore, A
	}
	; If Active Window is already Resized and Located on Left Half of the Current Monitor, Move Active Window to Right Half of Previous Monitor
	WinMove, A, , MonHlfRgt[MonQty] + HrzCrctn, MonTop[MonQty], MonHlfWdt[MonQty] + WdtCrctn, MonHgt[MonQty] + HgtCrctn
	Return
}














;     User Defined Values and Programs
; ****************************************
; ***** Gosub Label *****
; Exluded Programs, where the HotKeys will NOT WORK
ExcludPrgrm:
{
	WinGetClass, CNameHlfLft, A
	ExcludPrgrm := False
	; WorkerW ➔ Desktop
	If (CNameHlfLft == "WorkerW")
	{
		IgnorePrgrm := True
	}
	Return
}

; ***** Gosub Label *****
; Retrieves on which Monitor Number the Active Window is on
; Used to Move Window from Right to Left Monitors
WinCurntMon:
{
	WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
	WinHgtCtr := WinVrt + WinHgt / 2
	WinHrzCtr := WinHrz + WinWdt / 2

	Loop, %MonQty%
	{
		; If Center of Active Window is Located between defined Boundaries, Active Window is Located on Monitor #X
		If (WinHgtCtr >= MonTop[A_Index] AND WinHgtCtr <= MonBtm[A_Index] AND WinHrzCtr >= MonLft[A_Index] AND WinHrzCtr <= MonRgt[A_Index])
		{
			OnMonitor := A_Index
			; Once Matching Monitor Found, Stop the Search
			Break
		}
	}
	Return
}



onstart:
; *********************************************************************************
; 		Automatic Mapping of All Monitors, Move & Resize Windows  -START-
; *********************************************************************************

; Initialization of Arrays used
; Variables used for Temporary Monitor Number used to later organize Monitors in Ascending Order
; (1D Arrays)
MonTopTemp := []
MonBtmTemp := []
MonLftTemp := []
MonRgtTemp := []

; Variables used for Definitive Monitor Number in Ascending Order
; (1D Arrays)
MonTop := []
MonBtm := []
MonLft := []
MonRgt := []

; Variables used for Monitor Dimensions for Resizing to Half or Monitor and for Moving to another Monitor
; (1D Arrays)
MonHlfLft := []
MonHlfRgt := []
MonWdt := []
MonHlfWdt := []
MonHgt := []

; Variables of Definitive Monitor Number used to Move Windows Up and Down between Rows
; (2D Arrays)
MtxTop := []
MtxBtm := []
MtxLft := []
MtxRgt := []
MtxWdt := []
MtxHgt := []
MtxLstRow := []
MtxRowQty := []
Col_RowQty := []

; Variables used for Monitor Dimensions for Resizing to Quadrant of Monitor per Monitor Number
; (2D Arrays)
MonQdrTop := []
MonQdrLft := []
MonQdrBtm := []
MonQdrRgt := []
MonQdrWdt := []
MonQdrHgt := []

; Variables used for Monitor Dimensions for Resizing to Quadrant of Monitor per Column
; (3D Arrays)
MtxQdrTop := []
MtxQdrLft := []
MtxQdrBtm := []
MtxQdrRgt := []
MtxQdrWdt := []
MtxQdrHgt := []


; Variables used for Row Alignment with Bottom of Monitors
MonDIMBtmT := []

; Retrieve the Quantity of Monitors connected to system
SysGet, MonQty, MonitorCount

; Retrieve Coordinates and Dimensions of each Monitor
Loop, %MonQty%
{
	SysGet, MonWRKA, MonitorWorkArea, %A_Index%
	SysGet, MonDIM, Monitor, %A_Index%

	MonTopTemp[A_Index] := MonWRKATop
	MonBtmTemp[A_Index] := MonWRKABottom
	MonLftTemp[A_Index] := MonWRKALeft
	MonRgtTemp[A_Index] := MonWRKARight

	RowCntTemp = %RowCntTemp%, %MonWRKATop%
	ColCntTemp = %ColCntTemp%, %MonWRKALeft%

	; Variables used for Row Alignment with Bottom of Monitors
	; Options to Define Rows with Bottom of Monitors are Indicated Further in the Script
	MonDIMBtmT[A_Index] := MonDIMBottom
	RowCntBtmT = %RowCntBtmT%, %MonDIMBottom%
}

; Trim the first character (a comma ",") 
StringTrimLeft, RowCnt, RowCntTemp, 1
StringTrimLeft, ColCnt, ColCntTemp, 1
; Bottom of Row Alignment
StringTrimLeft, RowBtmCnt, RowCntBtmT, 1

; List out each unique value of Row and Column, defining boundaries
Sort RowCnt, N U D,
Sort ColCnt, N U D,
; Bottom of Row Alignment
Sort RowBtmCnt, N U D,

; Count the number of Rows and Columns
Loop, Parse, RowCnt, `,
{
	RowQty := A_Index
}
Loop, Parse, ColCnt, `,
{
	ColQty := A_Index
}
; Bottom of Row Alignment
Loop, Parse, RowBtmCnt, `,
{
	RowBtmQty := A_Index
}

; Separates each value of Row and Column into an Array Variable
RowValues := StrSplit(RowCnt, ",", " ")
ColValues := StrSplit(ColCnt, ",", " ")
; Bottom of Row Alignment
RowBtmValues := StrSplit(RowBtmCnt, ",", " ")

; ***** Monitor Mapping Initialization *****
; After counting how many Rows and Columns there are, the script will verify if
; there is a Monitor in each of the Rows/Columns Positions. If there is a gap
; (no Monitor in a Row/Column), the Space should not register in the Mapping

; Counter to Assign Monitor Number, from Top Left to Bottom Right
MonOrdr := 1

Loop, %RowQty%
; ******************************************************************
; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
; Loop, %RowBtmQty%
; ******************************************************************
{
	; Keep the current Row in Memory
	RowPosA_Index := A_Index
	
	Loop, %ColQty%
	{
		; Keep the current Column in Memory
		ColPosA_Index := A_Index
		
		Loop, %MonQty%
		{
			; Keep the current Monitor Number in Memory
			MonNrA_Index := A_Index
			
			If (ColValues[ColPosA_Index] == MonLftTemp[MonNrA_Index] AND RowValues[RowPosA_Index] == MonTopTemp[MonNrA_Index])
			; *********************************************************************************************************************
			; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
			; If (ColValues[ColPosA_Index] == MonLftTemp[MonNrA_Index] AND RowBtmValues[RowPosA_Index] == MonDIMBtmT[MonNrA_Index])
			; *********************************************************************************************************************
			{
				; Assign COORDINATES and DIMENSIONS of Monitors in Order, per MONITOR NUMBER, from Top Left to Bottom Right
				MonTop[MonOrdr] := MonTopTemp[MonNrA_Index]
				MonLft[MonOrdr] := MonLftTemp[MonNrA_Index]
				MonBtm[MonOrdr] := MonBtmTemp[MonNrA_Index]
				MonRgt[MonOrdr] := MonRgtTemp[MonNrA_Index]

				; Calculate COORDINATES and DIMENSIONS, per MONITOR NUMBER, to move Window to HALF OF MONITOR and to Another Monitor
				MonHlfLft[MonOrdr] := MonLft[MonOrdr]
				MonHlfRgt[MonOrdr] := Floor((MonLft[MonOrdr] + MonRgt[MonOrdr]) / 2)
				MonWdt[MonOrdr] := MonRgt[MonOrdr] - MonLft[MonOrdr]
				MonHlfWdt[MonOrdr] := Floor((MonRgt[MonOrdr] - MonLft[MonOrdr]) / 2)
				MonHgt[MonOrdr] := MonBtm[MonOrdr] - MonTop[MonOrdr]


				; ***** For Each Monitor Found, Assign Coordinates and Dimensions to 4 Quadrants *****
				; Quadrant Q1 of Current Monitor: TOP LEFT
				MonQdrTop[MonOrdr, 1] := MonTopTemp[MonNrA_Index]
				MonQdrLft[MonOrdr, 1] := MonLftTemp[MonNrA_Index]
				MonQdrBtm[MonOrdr, 1] := Floor(MonBtmTemp[MonNrA_Index] / 2)
				MonQdrRgt[MonOrdr, 1] := Floor(MonRgtTemp[MonNrA_Index] / 2)
				MonQdrWdt[MonOrdr, 1] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrHgt[MonOrdr, 1] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)

				; Quadrant Q2 of Current Monitor: BOTTOM LEFT
				MonQdrTop[MonOrdr, 2] := Floor(MonTopTemp[MonNrA_Index] + (MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
				MonQdrLft[MonOrdr, 2] := MonLftTemp[MonNrA_Index]
				MonQdrBtm[MonOrdr, 2] := MonBtmTemp[MonNrA_Index]
				MonQdrRgt[MonOrdr, 2] := Floor(MonRgtTemp[MonNrA_Index] / 2)
				MonQdrWdt[MonOrdr, 2] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrHgt[MonOrdr, 2] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)

				; Quadrant Q3 of Current Monitor: TOP RIGHT
				MonQdrTop[MonOrdr, 3] := MonTopTemp[MonNrA_Index]
				MonQdrLft[MonOrdr, 3] := Floor(MonLftTemp[MonNrA_Index] + (MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrBtm[MonOrdr, 3] := Floor(MonBtmTemp[MonNrA_Index] / 2)
				MonQdrRgt[MonOrdr, 3] := MonRgtTemp[MonNrA_Index]
				MonQdrWdt[MonOrdr, 3] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrHgt[MonOrdr, 3] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)

				; Quadrant Q4 of Current Monitor: BOTTOM RIGHT
				MonQdrTop[MonOrdr, 4] := Floor(MonTopTemp[MonNrA_Index] + (MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
				MonQdrLft[MonOrdr, 4] := Floor(MonLftTemp[MonNrA_Index] + (MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrBtm[MonOrdr, 4] := MonBtmTemp[MonNrA_Index]
				MonQdrRgt[MonOrdr, 4] := MonRgtTemp[MonNrA_Index]
				MonQdrWdt[MonOrdr, 4] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
				MonQdrHgt[MonOrdr, 4] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
				; **************************************************************************** 


				; When a Monitor is found at this ROW and COLUMN Position, increment Count for Next Monitor
				MonOrdr += 1
				; Once Matching Monitor Found, Skip to Next Column
				Break
			}
		}
	}
}

; ***** Monitor Mapping Initialization *****
; This part of the Script will Organize Monitors in Order, from Top to Bottom
Loop, %ColQty%
{
	ColPosA_Index := A_Index
	; On every new Column, Start Counting Rows at 1
	VrtMonOrdr := 1
	Loop, %RowQty%
	; ******************************************************************
	; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
	; Loop, %RowBtmQty%
	; ******************************************************************
	{
		RowPosA_Index := A_Index
		Loop, %MonQty%
		{
			VrtMonNrA_Index := A_Index
			If (ColValues[ColPosA_Index] == MonLftTemp[VrtMonNrA_Index] AND RowValues[RowPosA_Index] == MonTopTemp[VrtMonNrA_Index])
			; ***************************************************************************************************************************
			; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
			; If (ColValues[ColPosA_Index] == MonLftTemp[VrtMonNrA_Index] AND RowBtmValues[RowPosA_Index] == MonDIMBtmT[VrtMonNrA_Index])
			; ***************************************************************************************************************************
			{
				; Assign COORDINATES and DIMENSIONS of Monitors in Order, per ROW and COLUMN COLUMN (MATRIX), from Top to Bottom for each Column
				MtxTop[VrtMonOrdr, ColPosA_Index] := MonTopTemp[VrtMonNrA_Index]
				MtxLft[VrtMonOrdr, ColPosA_Index] := MonLftTemp[VrtMonNrA_Index]
				MtxBtm[VrtMonOrdr, ColPosA_Index] := MonBtmTemp[VrtMonNrA_Index]
				MtxRgt[VrtMonOrdr, ColPosA_Index] := MonRgtTemp[VrtMonNrA_Index]
				
				; Calculate COORDINATES and DIMENSIONS, per ROW and COLUMN COLUMN (MATRIX), to move Window to Another Monitor
				MtxWdt[VrtMonOrdr, ColPosA_Index] := MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]
				MtxHgt[VrtMonOrdr, ColPosA_Index] := MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]
				

				; ***** For Each Monitor Found, Assign Coordinates and Dimensions to 4 Quadrants *****
				; Quadrant Q1 of Current Monitor: TOP LEFT
				; Floor Function to be used in case there is a division of an odd number which would leave a "0.5".  Comparisons (Full Height and Quadrants) do not work without it.
				MtxQdrTop[VrtMonOrdr, ColPosA_Index, 1] := MonTopTemp[VrtMonNrA_Index]
				MtxQdrLft[VrtMonOrdr, ColPosA_Index, 1] := MonLftTemp[VrtMonNrA_Index]
				MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 1] := Floor(MonBtmTemp[VrtMonNrA_Index] / 2)
				MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 1] := Floor(MonRgtTemp[VrtMonNrA_Index] / 2)
				MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 1] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 1] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)

				; Quadrant Q2 of Current Monitor: BOTTOM LEFT
				MtxQdrTop[VrtMonOrdr, ColPosA_Index, 2] := Floor(MonTopTemp[VrtMonNrA_Index] + (MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
				MtxQdrLft[VrtMonOrdr, ColPosA_Index, 2] := MonLftTemp[VrtMonNrA_Index]
				MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 2] := MonBtmTemp[VrtMonNrA_Index]
				MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 2] := Floor(MonRgtTemp[VrtMonNrA_Index] / 2)
				MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 2] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 2] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)

				; Quadrant Q3 of Current Monitor: TOP RIGHT
				MtxQdrTop[VrtMonOrdr, ColPosA_Index, 3] := MonTopTemp[VrtMonNrA_Index]
				MtxQdrLft[VrtMonOrdr, ColPosA_Index, 3] := Floor(MonLftTemp[VrtMonNrA_Index] + (MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 3] := Floor(MonBtmTemp[VrtMonNrA_Index] / 2)
				MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 3] := MonRgtTemp[VrtMonNrA_Index]
				MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 3] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 3] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)

				; Quadrant Q4 of Current Monitor: BOTTOM RIGHT
				MtxQdrTop[VrtMonOrdr, ColPosA_Index, 4] := Floor(MonTopTemp[VrtMonNrA_Index] + (MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
				MtxQdrLft[VrtMonOrdr, ColPosA_Index, 4] := Floor(MonLftTemp[VrtMonNrA_Index] + (MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 4] := MonBtmTemp[VrtMonNrA_Index]
				MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 4] := MonRgtTemp[VrtMonNrA_Index]
				MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 4] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
				MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 4] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
				; **************************************************************************** 


				; Assign Numbering to Monitor on this Column
				Col_RowQty[ColPosA_Index] := VrtMonOrdr

				; When a Monitor is found at this ROW and COLUMN Position, increment Count for Next Monitor in this Column
				VrtMonOrdr += 1

				; Once Matching Monitor Found, Skip to Next Row
				Break
			}
		}
	}
}
return

2

Re: AHK: Запуск окна с перемещением

По какой причине показ окна не срабатывает, если раскомментировать  ",, Hide" ?

#SingleInstance Force
DetectHiddenWindows, On
SetTitleMatchMode, 2

Run Explorer.exe /n`,"C:\",, ;Hide
ID := WinWaitCreated("ahk_class CabinetWClass")
WinWaitActive, ahk_id %ID%
winmaximize, ahk_id %ID%
WinShow, ahk_id %ID%

/*
  Wait for a window to be created, returns 0 on timeout and ahk_id otherwise
  Parameter are the same as WinWait, see http://ahkscript.org/docs/commands/WinWait.htm
  Forum: http://ahkscript.org/boards/viewtopic.php?f=6&t=1274&p=8517#p8517
*/
WinWaitCreated( WinTitle:="", WinText:="", Seconds:=0, ExcludeTitle:="", ExcludeText:="" ) {
    ; HotKeyIt - http://ahkscript.org/boards/viewtopic.php?t=1274
    static Found := 0, _WinTitle, _WinText, _ExcludeTitle, _ExcludeText 
         , init := DllCall( "RegisterShellHookWindow", "UInt",A_ScriptHwnd )
         , MsgNum := DllCall( "RegisterWindowMessage", "Str","SHELLHOOK" )
         , cleanup:={base:{__Delete:"WinWaitCreated"}}
  If IsObject(WinTitle)   ; cleanup
    return DllCall("DeregisterShellHookWindow","PTR",A_ScriptHwnd)
  else if (Seconds <> MsgNum){ ; User called the function
    Start := A_TickCount, _WinTitle := WinTitle, _WinText := WinText
    ,_ExcludeTitle := ExcludeTitle, _ExcludeText := ExcludeText
    ,OnMessage( MsgNum, A_ThisFunc ),  Found := 0
    While ( !Found && ( !Seconds || Seconds * 1000 < A_TickCount - Start ) ) 
      Sleep 16                                                         
    Return Found,OnMessage( MsgNum, "" )
  }
  If ( WinTitle = 1   ; window created, check if it is our window
    && ExcludeTitle = A_ScriptHwnd
    && WinExist( _WinTitle " ahk_id " WinText,_WinText,_ExcludeTitle,_ExcludeText))
    WinWait % "ahk_id " Found := WinText ; wait for window to be shown
}

3

Re: AHK: Запуск окна с перемещением

То есть, в коде окно должно открываться в невидимом режиме, потом разворачиваться, и показываться.

4

Re: AHK: Запуск окна с перемещением

john_dease пишет:

Возник вопрос - как на AHK запускать это окно сразу в развернутом слева состоянии?

Run Explorer.exe /n`, C:,, Max

Так пробовали?

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

5

Re: AHK: Запуск окна с перемещением

teadrinker

Я собирался вместо строки "winmaximize, ahk_id %ID%", потом поставить отсылку к подпрограмме максимизирующей окно слева, вполовину экрана. То есть, запустить окно в скрытом виде, переместить влево (или как в последнем примере, просто максимизировать), и после развертывания слева, отобразить. Только в последнем примере кода по какой-то причине окна из скрытого режима не возвращаются.

6

Re: AHK: Запуск окна с перемещением

Не знаю, почему не работает, событие создания окна не отлавливается.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

7

Re: AHK: Запуск окна с перемещением

Этот ваш вариант вроде как идентичен отображению со скрытием - https://www.autohotkey.com/boards/viewt … 97#p170997. То есть, окно сразу разворачивается.

FolderPath := A_MyDocuments

DetectHiddenWindows, On
windowsArray := []
WinGet, List, List, ahk_class CabinetWClass
Loop % List
   windowsArray[List%A_Index%] := true

Run, explorer /open`,"%FolderPath%",, Hide
Loop  {
   WinGet, List, List, ahk_class CabinetWClass
   Loop % List
      if !windowsArray.HasKey(List%A_Index%) && hwnd := List%A_Index%
         break 2
}
;MsgBox, % WinExist("ahk_id" hwnd)

winmaximize, ahk_id %hwnd%