help migration to v2 syntax

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
dmitry
Posts: 2
Joined: 16 Sep 2021, 02:33
Contact:

help migration to v2 syntax

Post by dmitry » 04 Feb 2023, 05:57

Hello

I'm probably getting old and stupid but I cannot neither figure out nor rtfm how to rewrite my old ahk command to v2.
The command supposed to maximize/restore current window a-la ubuntu, and no matter how I try to follow the syntax an error, there's one or another syntax error.
A hint would be very much appreciated!

Code: Select all

; maximize
!F10::
SetTitleMatchMode "RegEx"
IfWinActive, .*
{
	WinGet, MAX, MinMax
	if (MAX = 0) {
		WinMaximize
	} else {
		WinRestore
	}
}

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

Re: help migration to v2 syntax

Post by mikeyww » 04 Feb 2023, 06:42

Code: Select all

#Requires AutoHotkey v2.0
winTitle := "ahk_exe notepad.exe"
#HotIf WinActive(winTitle)
!F10::WinGetMinMax() ? WinRestore() : WinMaximize()
#HotIf

just me
Posts: 9406
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: help migration to v2 syntax

Post by just me » 05 Feb 2023, 06:53

or maybe

Code: Select all

#Requires AutoHotkey v2.0.0
#HotIf WinExist("A")
!F10:: {
If WinGetMinMax() = 0
	WinMaximize()
Else
	WinRestore()
}
#HotIf

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

Re: help migration to v2 syntax

Post by mikeyww » 05 Feb 2023, 08:05

Yes, but #HotIf is not needed to work with the active window.

Code: Select all

#Requires AutoHotkey v2.0
!F10::WinGetMinMax("A") ? WinRestore("A") : WinMaximize("A")
Your script (just me) might be faster, but I did not time them.

dmitry
Posts: 2
Joined: 16 Sep 2021, 02:33
Contact:

Re: help migration to v2 syntax

Post by dmitry » 10 Feb 2023, 05:29

Thank you very much everyone! This version works - I'll leave it here if anyone needs to google that in the future:

Code: Select all

#Requires AutoHotkey v2.0
; maximize / restore current window
SetTitleMatchMode "RegEx"
#HotIf WinActive(".*")
!F10:: {
If WinGetMinMax() = 0
	WinMaximize()
Else
	WinRestore()
}
#HotIf

Post Reply

Return to “Ask for Help (v2)”