Site icon This and That

Working with Asus Aura SDK(Asus ROG Strix G15 keyboard RGB Lighting Library)

There are 2 prereqs for this to work.

  1. Aura SDK
  2. Python PyWin32 plugin

Aura SDK, it turns out, was bundled with the Armoury Crate and associated programs that were installed from the factory.

The PyWin32 Readme cautioned to not use pip, hence I used the binary installer instead. Like most PCs nowadays, my laptop architecture is amd64. I used scoop to install python 3.10.8. The installer we need is pywin32-304.win-amd64-py3.10.exe . The installation was easy and seamless.

From hereon, you have full access to your keyboard Lights. The sky is the limit on what you can do with 192 lights.

A simple Python code that sets all the keys to Red is

import win32com.client
auraSdk = win32com.client.Dispatch("aura.sdk.1")
auraSdk.SwitchMode()
devices = auraSdk.Enumerate(0)   # 0 means ALL
for dev in devices:                      # Use enumeration
    for i in range(dev.Lights.Count):    # Use index
        dev.Lights(i).color = 0x0000FF00 # 0x00BBGGRR , i.e. RGB with Red on LSB
    dev.Apply()

One particular trick that can be used to introspect the COMObjects here is using dir() builtin of Python. For example, to enumerate all the methods/fields of an object, we can use

>>> dir(keyboard)
['AddRef', 'Apply', 'GetIDsOfNames', 'GetTypeInfo', 'GetTypeInfoCount', 'Height', 'Invoke', 'Key', 'Keys', 'Lights', 'Name', 'QueryInterface', 'Release', 'Type', 'Width', '_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '_UpdateWithITypeInfo_', '__AttrToID__', '__LazyMap__', '__bool__', '__call__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_builtMethods_', '_dir_ole_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']
>>> 

To remove all the internal methods, we can use this nifty list comprehension. This way, even if the documentation site goes down, we still have a way to figure out what variables exist.

>>> [x for x in dir(keyboard) if x[0] != '_']
['AddRef', 'Apply', 'GetIDsOfNames', 'GetTypeInfo', 'GetTypeInfoCount', 'Height', 'Invoke', 'Key', 'Keys', 'Lights', 'Name', 'QueryInterface', 'Release', 'Type', 'Width']
>>>

Here is the mapping of key names to hex. I am pretty sure this is not accurate, but here it is in case the documentation website goes down.

Key NameKey CodeNote
ROG_KEY_ESCAPE0x0001
ROG_KEY_10x0002
ROG_KEY_20x0003
ROG_KEY_30x0004
ROG_KEY_40x0005
ROG_KEY_50x0006
ROG_KEY_60x0007
ROG_KEY_70x0008
ROG_KEY_80x0009
ROG_KEY_90x000A
ROG_KEY_00x000B
ROG_KEY_MINUS0x000C- on main keyboard
ROG_KEY_EQUALS0x000D
ROG_KEY_BACK0x000Ebackspace
ROG_KEY_TAB0x000F
ROG_KEY_Q0x0010
ROG_KEY_W0x0011
ROG_KEY_E0x0012
ROG_KEY_R0x0013
ROG_KEY_T0x0014
ROG_KEY_Y0x0015
ROG_KEY_U0x0016
ROG_KEY_I0x0017
ROG_KEY_O0x0018
ROG_KEY_P0x0019
ROG_KEY_LBRACKET0x001A
ROG_KEY_RBRACKET0x001B
ROG_KEY_RETURN0x001CEnter on main keyboard
ROG_KEY_LCONTROL0x001D
ROG_KEY_A0x001E
ROG_KEY_S0x001F
ROG_KEY_D0x0020
ROG_KEY_F0x0021
ROG_KEY_G0x0022
ROG_KEY_H0x0023
ROG_KEY_J0x0024
ROG_KEY_K0x0025
ROG_KEY_L0x0026
ROG_KEY_SEMICOLON0x0027
ROG_KEY_APOSTROPHE0x0028
ROG_KEY_GRAVE0x0029Accent grave
ROG_KEY_LSHIFT0x002A
ROG_KEY_BACKSLASH0x002B
ROG_KEY_Z0x002C
ROG_KEY_X0x002D
ROG_KEY_C0x002E
ROG_KEY_V0x002F
ROG_KEY_B0x0030
ROG_KEY_N0x0031
ROG_KEY_M0x0032
ROG_KEY_COMMA0x0033
ROG_KEY_PERIOD0x0034. on main keyboard
ROG_KEY_SLASH0x0035/ on main keyboard
ROG_KEY_RSHIFT0x0036
ROG_KEY_MULTIPLY0x0037* on numeric keypad
ROG_KEY_LMENU0x0038Left Alt
ROG_KEY_SPACE0x0039
ROG_KEY_CAPITAL0x003A
ROG_KEY_F10x003B
ROG_KEY_F20x003C
ROG_KEY_F30x003D
ROG_KEY_F40x003E
ROG_KEY_F50x003F
ROG_KEY_F60x0040
ROG_KEY_F70x0041
ROG_KEY_F80x0042
ROG_KEY_F90x0043
ROG_KEY_F100x0044
ROG_KEY_NUMLOCK0x0045
ROG_KEY_SCROLL0x0046Scroll Lock
ROG_KEY_NUMPAD70x0047
ROG_KEY_NUMPAD80x0048
ROG_KEY_NUMPAD90x0049
ROG_KEY_SUBTRACT0x004A- on numeric keypad
ROG_KEY_NUMPAD40x004B
ROG_KEY_NUMPAD50x004C
ROG_KEY_NUMPAD60x004D
ROG_KEY_ADD0x004E+ on numeric keypad
ROG_KEY_NUMPAD10x004F
ROG_KEY_NUMPAD20x0050
ROG_KEY_NUMPAD30x0051
ROG_KEY_NUMPAD00x0052
ROG_KEY_DECIMAL0x0053. on numeric keypad
ROG_KEY_F110x0057
ROG_KEY_F120x0058
ROG_KEY_NUMPADENTER0x009CEnter on numeric keypad
ROG_KEY_RCONTROL0x009D
ROG_KEY_DIVIDE0x00B5/ on numeric keypad
ROG_KEY_SYSRQ0x00B7
ROG_KEY_RMENU0x00B8Right Alt
ROG_KEY_PAUSE0x00C5Pause
ROG_KEY_HOME0x00C7Home on arrow keypad
ROG_KEY_UP0x00C8Up on arrow keypad
ROG_KEY_PRIOR0x00C9PgUp on arrow keypad
ROG_KEY_LEFT0x00CBLeft on arrow keypad
ROG_KEY_RIGHT0x00CDRight on arrow keypad
ROG_KEY_END0x00CFEnd on arrow keypad
ROG_KEY_DOWN0x00D0Down on arrow keypad
ROG_KEY_NEXT0x00D1PgDn on arrow keypad
ROG_KEY_INSERT0x00D2Insert on arrow keypad
ROG_KEY_DELETE0x00D3Delete on arrow keypad
ROG_KEY_LWIN0x00DBLeft Windows key
ROG_KEY_APPS0x00DDAppMenu key
ROG_KEY_FN0x0100Function key

References

Exit mobile version