Skip to content

Instantly share code, notes, and snippets.

@10se1ucgo
Created March 15, 2016 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 10se1ucgo/0bf8e8f6dd9f51fd04d9 to your computer and use it in GitHub Desktop.
Save 10se1ucgo/0bf8e8f6dd9f51fd04d9 to your computer and use it in GitHub Desktop.
#!python3
from adl3 import *
class ADLError(Exception):
pass
def load_driver():
if ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1) != ADL_OK:
raise ADLError("Failed to create ADL main control.")
return True
def set_saturation(saturation_value):
load_driver()
adapter_count = c_int()
if ADL_Adapter_NumberOfAdapters_Get(byref(adapter_count)) != ADL_OK:
raise ADLError("Failed to get adapter count.")
if adapter_count.value <= 0:
raise ADLError("The adpater count is not a positive non-zero integer!")
adapter_info = (AdapterInfo * adapter_count.value)()
ADL_Adapter_AdapterInfo_Get(adapter_info, sizeof(AdapterInfo) * adapter_count.value)
for x in range(adapter_count.value):
adapter_index = adapter_info[x].iAdapterIndex
display_count = c_int()
dp_array = POINTER((ADLDisplayInfo * display_count.value))()
display_info = cast(dp_array, LPADLDisplayInfo)
if ADL_Display_DisplayInfo_Get(adapter_index, byref(display_count), byref(display_info), 0) != ADL_OK:
continue
for y in range(display_count.value):
# oh my god this is so ugly what the fuck
if ((ADL_DISPLAY_DISPLAYINFO_DISPLAYCONNECTED | ADL_DISPLAY_DISPLAYINFO_DISPLAYMAPPED) !=
(ADL_DISPLAY_DISPLAYINFO_DISPLAYCONNECTED | ADL_DISPLAY_DISPLAYINFO_DISPLAYMAPPED &
display_info[y].iDisplayInfoValue)):
continue
display_index = display_info[y].displayID.iDisplayLogicalIndex
current, default, minimum, maximum, step = c_int(), c_int(), c_int(), c_int(), c_int()
if ADL_Display_Color_Get(adapter_index, display_index, ADL_DISPLAY_COLOR_SATURATION, byref(current),
byref(default), byref(minimum), byref(maximum), byref(step)) != ADL_OK:
raise ADLError("Could not get display colors!")
if minimum.value > saturation_value or maximum.value < saturation_value:
raise ADLError("Saturation value not within range!")
if ADL_Display_Color_Set(adapter_index, display_index, ADL_DISPLAY_COLOR_SATURATION,
saturation_value) == ADL_OK:
print("Saturation set to {sat}".format(sat=saturation_value))
ADL_Main_Control_Destroy()
if __name__ == "__main__":
set_saturation(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment