Help with 3rd-party DLLs and CLR.ahk

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hylotropy
Posts: 14
Joined: 28 Jan 2021, 23:01

Help with 3rd-party DLLs and CLR.ahk

21 Apr 2021, 00:51

I tried to translate the following powershell script to autohotkey but got an error 0x80131509.
ILSpy : https://imgur.com/a/5jtXOxG

powershell

Code: Select all

Add-Type -Path "C:\Users\Admin\Desktop\OpenHardwareMonitor\OpenHardwareMonitorLib.dll"
$Comp = New-Object -TypeName OpenHardwareMonitor.Hardware.Computer
$Comp.Open()
$Comp.CPUEnabled = $true
$Comp.Hardware[0].HardwareType    #return "Cpu"
autohotkey

Code: Select all

SetWorkingDir %A_ScriptDir%  ;
OpenHardwareMonitorLibPath:=A_ScriptDir "\OpenHardwareMonitorLib.dll"
asm := CLR_LoadLibrary(OpenHardwareMonitorLibPath)
computer := CLR_CreateObject(asm, "OpenHardwareMonitor.Hardware.Computer")
computer.Open()
computer.CpuEnabled  :=computer.HDDEnabled := computer.RAMEnabled := 1 
Hardwares:= computer.Hardware
msgbox,%  ComObjType(Hardwares[0])  ;return  9
msgbox,%  ComObjType(Hardwares[1])  ;return  9
msgbox,%  ComObjType(Hardwares[2])  ;return  9
msgbox,%  ComObjType(Hardwares[0].HardwareType)  ; Error:  0x80131509 -  Specifically: HardwareType

What is the difference between clr.ahk and pythonnet? It is easy to use OpenHardwareMonitorLib.dll in vb, powershell, and even python (pythonnet), I don't understand why it is so difficult to use OpenHardwareMonitorLib.dll in autohotkey.

Code: Select all

import clr
clr.AddReference("c:/OpenHardwareMonitorLib.dll") 
from OpenHardwareMonitor.Hardware import Computer 
 
computer_tmp = Computer() 
computer_tmp.CPUEnabled = True 
computer_tmp.Open()
print (computer_tmp.Hardware[0].HardwareType)  # CPU

Image
Attachments
OpenHardwareMonitorLib.zip
(119.35 KiB) Downloaded 23 times
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

Re: Help with 3rd-party DLLs and CLR.ahk

23 Apr 2021, 11:19

Not having any luck with AHK and this lib so far, but I'll keep trying.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], mcd, Nerafius and 112 guests