How to access a file’s properties on Windows?

Here is a function which reads all file attributes as a dictionary: import win32api #============================================================================== def getFileProperties(fname): #============================================================================== “”” Read all properties of the given file return them as a dictionary. “”” propNames = (‘Comments’, ‘InternalName’, ‘ProductName’, ‘CompanyName’, ‘LegalCopyright’, ‘ProductVersion’, ‘FileDescription’, ‘LegalTrademarks’, ‘PrivateBuild’, ‘FileVersion’, ‘OriginalFilename’, ‘SpecialBuild’) props = {‘FixedFileInfo’: None, ‘StringFileInfo’: None, ‘FileVersion’: None} try: … Read more

Power off an USB device in software on Windows

Some USB hubs have the ability to turn power off to its downstream devices. “Is it possible to power up ports on a USB hub from Ubuntu?” https://askubuntu.com/questions/149242/is-it-possible-to-power-up-ports-on-a-usb-hub-from-ubuntu Which points to some c source for hub-ctrl.c See: http://www.gniibe.org/development/ac-power-control-by-USB-hub/index I tested this on Ubuntu with a Dream-Cheeky USB LED unit, and it did seem to turn … Read more

How to programmatically move Windows taskbar?

I also have this need on Windows 7. Here is my take to do this using autohotkey script: ; This script will try to drag and move the taskbar to where the *current* mouse ; cursor is ; 0x111: WM_COMMAND, 424: lock/unlock taskbar, http://www.codeproject.com/KB/miscctrl/Taskbar_Manipulation.aspx RegRead, TaskbarLocked, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove If TaskbarLocked = 0 SendMessage 0x111, … Read more

Win10 dark theme – how to use in WINAPI?

See https://github.com/ysc3839/win32-darkmode This guy has it all laid out in some nice reusable code (MIT license). It seems that Dark Mode is still an area of development in Windows 10, but I believe that Microsoft will eventually properly document and expose it to desktop apps. Until then, we are stuck with undocumented ordinal-only imports, then … Read more