Problem with unhiding a window

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
afshindavoudy
Posts: 44
Joined: 10 Jan 2024, 13:25

Problem with unhiding a window

Post by afshindavoudy » 08 Mar 2024, 05:34

I want to know why this script cannot unhide windows?

Code: Select all

hidden := []

F2:: {
	hwnd := WinExist('A')
	hidden.Push(hwnd)
	WinHide(hwnd)
}

F3:: {
	; MsgBox (hidden.Length) ; This detect the length correctly
	loop(hidden){
		WinShow(hidden[A_Index])
		WinActivate(hidden[A_Index])
	}
}

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Problem with unhiding a window

Post by mikeyww » 08 Mar 2024, 05:50

Hello,

hidden is an array, not a number.

Syntax for Loop:

Loop [Count]
Count:

Type: Integer

If omitted, the loop continues indefinitely until a Break or Return is encountered. Otherwise, specify how many times (iterations) to perform the loop. However, an explicit blank value or number less than 1 causes the loop to be skipped entirely.
Explained: Length property

Code: Select all

#Requires AutoHotkey v2.0
hidden := []

F2:: {
 Try {
  hidden.Push(WinExist('A'))
  WinHide()
 }
}

F3:: {
 DetectHiddenWindows True
 While hidden.Length
  If WinExist(hidden.RemoveAt(1))
   WinShow(), WinActivate()
}

afshindavoudy
Posts: 44
Joined: 10 Jan 2024, 13:25

Re: Problem with unhiding a window

Post by afshindavoudy » 08 Mar 2024, 06:06

@mikeyww
Yes, that was my mistake.
Thanks

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Problem with unhiding a window

Post by mikeyww » 08 Mar 2024, 06:12

This version may be better.

Code: Select all

#Requires AutoHotkey v2.0
hidden := []

F2:: {
 If hWnd := WinActive('A')
  hidden.Push(hWnd), WinHide()
}

F3:: {
 DetectHiddenWindows True
 While hidden.Length
  If WinExist(hidden.RemoveAt(1))
   WinShow(), WinActivate()
}

Post Reply

Return to “Ask for Help (v2)”