 ; This function requires A_Unicode and Vista or later.
 Static FooterText := ""
 ; Error Flags
-Static S_OK = 0x0, E_OUTOFMEMORY = 0x8007000E, E_INVALIDARG  = 0x80070057, E_FAIL = 0x80004005
+Static S_OK = 0x0, E_OUTOFMEMORY = 0x8007000E, E_INVALIDARG = 0x80070057, E_FAIL = 0x80004005
 
 ;General Flags
 Static flags = 0x1011, TDF_VERIFICATION_FLAG_CHECKED = 0x0100, TDF_CALLBACK_TIMER := 0X0800




GetResList(targMonitorNum, dispMonNamesNo, iDevNumArray, dispMonNames, ByRef ResArray, allModes, stopAtCurrent := 0)
{
; From Checkmodes, stopAtCurrent is first -1 then (default) 0
static checkDefMissingMsg := 0, ENUM_CURRENT_SETTINGS := -1
ResList := "", Strng := ""

iModeCt := 0, checkDefMissing := 0 iModeval := (stopAtCurrent)? ENUM_CURRENT_SETTINGS: 0
scrWidth := 0, scrHeight := 0, scrDPI := 0, scrInterlace := 0, scrFreq := 0
scrWidthlast := 0, scrHeightlast := 0, scrDPIlast := 0, scrInterlacelast := 0, scrFreqlast := 0


	while GetDisplayData(targMonitorNum, , , , scrWidth, scrHeight, scrFreq, scrInterlace, scrDPI, iModeval, (PrgLnch.Monitor != targMonitorNum))
	
	{
	;imodeCt == 0 caches the data for EnumSettings

		;For "Incompatible" resolution detection,: first check if the current settings are missing from the list and replace it .
		if (!checkDefMissing && !stopAtCurrent && PrgLnchOpt.scrWidthDef && (scrWidth > PrgLnchOpt.scrWidthDef))
		{
			if ((!FindResMatch(iModeCt, ResArray)) || (scrWidthLast != PrgLnchOpt.scrWidthDef))
			{
			iModeCt +=1
			ResArray[iModeCt, 1] := PrgLnchOpt.scrWidthDef
			ResArray[iModeCt, 2] := PrgLnchOpt.scrHeightDef
			ResArray[iModeCt, 3] := PrgLnchOpt.scrFreqDef
			Strng := PrgLnchOpt.scrWidthDef . " `, " . PrgLnchOpt.scrHeightDef . " @ " . PrgLnchOpt.scrFreqDef . "Hz |"
			ResList .= Strng

				if (!checkDefMissingMsg)
				{
				;note-msgbox isn't modal if called from function
				MsgBox, 8192, Default Resolution, % "The current desktop resolution of " PrgLnchOpt.scrWidthDef " X " PrgLnchOpt.scrHeightDef " does not appear in the list of resolution modes for the active monitor. The mode has been inserted to the list of resolutions, however changes to this, or any other resolution mode in this PrgLnch instance will not work properly, if at all.`n`nIt's recommended the current desktop resolution be permanently changed to one which is more compatible with the driver.`nTo do so, from PrgLnch Options, select " . """" . "None" . """" . " in Shortcut slots, and choose " . """" . "Dynamic" . """" . " in the Res Options, and then select an alternative resolution mode from the list. Be sure to return the selection in Res Options to " . """" . "Temporary" . """" . " if that is the preference."
				checkDefMissingMsg := 1
				}
			}
		checkDefMissing := 1
		}



		if (scrWidthlast == scrWidth)
		{
			;many iModeCts here are equivalent for the above params. scrFreq & scrHeight may vary for a subset of those
			if ((allModes && (scrHeightlast == scrHeight || scrFreqlast == scrFreq)) || (scrHeightlast != scrHeight || scrFreqlast != scrFreq))
			{
			iModeCt += 1
			Strng := scrWidth . " `, " . scrHeight . " @ " . scrFreq . "Hz |"
			ResArray[iModeCt, 1] := scrWidth
			ResArray[iModeCt, 2] := scrHeight
			ResArray[iModeCt, 3] := scrFreq
				if (stopAtCurrent)
				{
				PrgLnchOpt.scrWidthDef := scrWidth
				PrgLnchOpt.scrHeightDef := scrHeight
				PrgLnchOpt.scrFreqDef := scrFreq

				return Strng
				}
			ResList .= Strng
			scrHeightlast := scrHeight
			scrFreqlast := scrFreq
			scrDPIlast := scrDPI
			scrInterlacelast := scrInterlace
			}
		}
		else
		{
			if ((AllModes && scrHeightlast == scrHeight && scrFreqlast == scrFreq) || ((scrHeightlast != scrHeight || scrFreqlast != scrFreq)))
			{
			iModeCt += 1
			scrWidthlast := scrWidth
			scrHeightlast := scrHeight
			scrDPIlast := scrDPI
			scrInterlacelast := scrInterlace
			scrFreqlast := scrFreq

			;https://autohotkey.com/boards/viewtopic.php?f=5&t=23021&p=108567#p108567
			Strng := scrWidth . " `, " . scrHeight . " @ " . scrFreq "Hz |"

			ResArray[iModeCt, 1] := scrWidth
			ResArray[iModeCt, 2] := scrHeight
			ResArray[iModeCt, 3] := scrFreq
				if (stopAtCurrent)
				{
					PrgLnchOpt.scrWidthDef := scrWidth
					PrgLnchOpt.scrHeightDef := scrHeight
					PrgLnchOpt.scrFreqDef := scrFreq
					return Strng
				}
				else
				{
				ResList .= Strng
				}
			}
		}
		iModeval += 1
	}
return ResList
}

			if (tmp < 0)
			return "Cancelled!"

			strRetVal := ChangeResolution(dispMonNames, targMonitorNum)

			if (strRetVal)
			return % "Requested resolution change did not work. Reason: `n" strRetVal
