;--------------------------------------------------------------------------------------------------------------- ; CHANGELOG: ; ; Oct 11 2023: Initial release by Glisense ltd ; ; Current script is designed for use together with KeyboardExtension® (https://keyboardextension.com) ; ; For the latest version, description and licensing terms go to https://keyboardextension.com/plugins/ca28c979 ; ;--------------------------------------------------------------------------------------------------------------- #NoTrayIcon Persistent info := GetAllDisplaysFrequencies() Names := AhkToJSON(info[1]) Values := AhkToJSON(info[2]) ; MsgBox Names . '`n' . Values GetAllDisplaysFrequencies() { static DISPLAY_DEVICE_ATTACHED_TO_DESKTOP := 1 Names := [] Frequencies := [] size := 8 + 416 * 2 NumPut('UInt', size, DISPLAY_DEVICE := Buffer(size, 0)) i := 0 while DllCall('EnumDisplayDevices', 'Ptr', 0, 'UInt', A_Index - 1, 'Ptr', DISPLAY_DEVICE, 'UInt', 0) { if !(NumGet(DISPLAY_DEVICE, 4 + (32 + 128) * 2, 'UInt') & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { continue } ; MsgBox StrGet(DISPLAY_DEVICE.ptr + 4) Names.Push({id: ++i, value: StrGet(DISPLAY_DEVICE.ptr + 4 + (32 + 128)*2 + 4)}) Frequencies.Push({id: i, value: GetDisplayFrequency(DISPLAY_DEVICE.ptr + 4)}) } return [Names, Frequencies] GetDisplayFrequency(pName) { static DM_DISPLAYFREQUENCY := 0x400000, ENUM_CURRENT_SETTINGS := -1 , dmSize := 220, dmSizeOffset := 68, dmDisplayFrequencyOffset := 184 NumPut('Int', dmSize, 'Int', DM_DISPLAYFREQUENCY, DEVMODE := Buffer(dmSize, 0), dmSizeOffset) DllCall('EnumDisplaySettings', 'Ptr', pName, 'UInt', ENUM_CURRENT_SETTINGS, 'Ptr', DEVMODE) return NumGet(DEVMODE, dmDisplayFrequencyOffset, 'UInt') } } AhkToJSON(obj, indent := '') { static document := '', JS if !document { document := ComObject("HTMLFILE") document.write('') JS := document.parentWindow (document.documentMode < 9 && JS.execScript()) } if indent = true { if IsObject(obj) { isArray := Type(obj) = 'Array' enumerable := Type(obj) = 'Object' ? obj.OwnProps() : obj str := '' for k, v in enumerable str .= (A_Index = 1 ? '' : ',') . (isArray ? '' : %A_ThisFunc%(k, true) . ':') . %A_ThisFunc%(v, true) return isArray ? '[' str ']' : '{' str '}' } if IsNumber(obj) && Type(obj) != 'String' return obj for k, v in [['\', '\\'], [A_Tab, '\t'], ['"', '\"'], ['/', '\/'], ['`n', '\n'], ['`r', '\r'], [Chr(12), '\f'], [Chr(8), '\b']] obj := StrReplace(obj, v[1], v[2]) return '"' obj '"' } sObj := %A_ThisFunc%(obj, true) return JS.eval('JSON.stringify(' . sObj . ',"","' . indent . '")') }