<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16971&amp;type=atom" />
	<updated>2022-02-15T14:32:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16971</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152212#p152212" />
			<content type="html"><![CDATA[<p>Да, нет температуры CPU.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-15T14:32:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152212#p152212</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152211#p152211" />
			<content type="html"><![CDATA[<p>А что там можно вырезать кроме определения температуры у nvidia карточек?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-02-15T14:29:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152211#p152211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152210#p152210" />
			<content type="html"><![CDATA[<p>Удалено.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-02-15T14:07:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152210#p152210</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152208#p152208" />
			<content type="html"><![CDATA[<p>Надо сказать, что скрипт должен быть запущен от администратора.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-02-15T11:37:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152208#p152208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152205#p152205" />
			<content type="html"><![CDATA[<p>Ну или можно через повершелл запускать.<br /><a href="https://audministrator.wordpress.com/2019/10/19/powershell-monitor-cpu-cores-temperatures/">https://audministrator.wordpress.com/20 … peratures/</a><br /></p><div class="codebox"><pre><code>OpenHardwareMonitorLib := A_ScriptDir &quot;\OpenHardwareMonitorLib.dll&quot;
cSharp =
(
using System.Text;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

public class ps
{
	public string RunScript(string scriptText)
	{
		Runspace runspace = RunspaceFactory.CreateRunspace();
		runspace.Open();

		Pipeline pipeline = runspace.CreatePipeline();
		pipeline.Commands.AddScript(scriptText);
		pipeline.Commands.Add(&quot;Out-String&quot;);

		Collection&lt;PSObject&gt; results = pipeline.Invoke();

		runspace.Close();
		return results[0].ToString();
		
		/*
		StringBuilder stringBuilder = new StringBuilder();
		foreach (PSObject obj in results)
		{
			stringBuilder.AppendLine(obj.ToString());
		}

		return stringBuilder.ToString();
		*/
	}
}
)

asm := CLR_CompileC#( cSharp, &quot;System.Core.dll | C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll&quot; )
ps := asm.CreateInstance(&quot;ps&quot;)
psCode =
(
[Reflection.Assembly]::LoadFile(&quot;%OpenHardwareMonitorLib%&quot;) | Out-Null
$Comp = New-Object -TypeName OpenHardwareMonitor.Hardware.Computer
$Comp.Open()
$Comp.CPUEnabled = $true
$Comp.RAMEnabled = $true
$Comp.MainboardEnabled = $true
$Comp.FanControllerEnabled = $true
$Comp.GPUEnabled = $true
$Comp.HDDEnabled = $true
ForEach ($HW in $Comp.Hardware) {
$HW.Update()
    $hw.HardwareType.ToString() + &#039; - &#039; + $hw.name.ToString()
    If ( $hw.HardwareType -eq &quot;CPU&quot;){
        ForEach ($Sensor in $HW.Sensors) {
        If ($Sensor.SensorType -eq &quot;Temperature&quot;){
            $Sensor.Name + &#039; - Temp : &#039; + $Sensor.Value.ToString() + &#039; C - Min. : &#039; + $Sensor.Min.ToString() + &#039; C - Max : &#039; + $Sensor.Max.ToString() + &#039; C&#039;
        }
      }
    }
    # $hw.Sensors
    $hw.SubHardware
}
$Comp.Close()
)
msgbox % ps.RunScript(psCode)

; ==========================================================
;                  .NET Framework Interop
;      http://www.autohotkey.com/forum/topic26191.html
; ==========================================================
;
;   Author:     Lexikos
;   Version:    1.2
;   Requires:	AutoHotkey_L v1.0.96+
;

CLR_LoadLibrary(AssemblyName, AppDomain=0)
{
	if !AppDomain
		AppDomain := CLR_GetDefaultDomain()
	e := ComObjError(0)
	Loop 1 {
		if assembly := AppDomain.Load_2(AssemblyName)
			break
		static null := ComObject(13,0)
		args := ComObjArray(0xC, 1),  args[0] := AssemblyName
		typeofAssembly := AppDomain.GetType().Assembly.GetType()
		if assembly := typeofAssembly.InvokeMember_3(&quot;LoadWithPartialName&quot;, 0x158, null, null, args)
			break
		if assembly := typeofAssembly.InvokeMember_3(&quot;LoadFrom&quot;, 0x158, null, null, args)
			break
	}
	ComObjError(e)
	return assembly
}

CLR_CreateObject(Assembly, TypeName, Args*)
{
	if !(argCount := Args.MaxIndex())
		return Assembly.CreateInstance_2(TypeName, true)
	
	vargs := ComObjArray(0xC, argCount)
	Loop % argCount
		vargs[A_Index-1] := Args[A_Index]
	
	static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
	
	return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
}

CLR_CompileC#(Code, References=&quot;&quot;, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	return CLR_CompileAssembly(Code, References, &quot;System&quot;, &quot;Microsoft.CSharp.CSharpCodeProvider&quot;, AppDomain, FileName, CompilerOptions)
}

CLR_CompileVB(Code, References=&quot;&quot;, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	return CLR_CompileAssembly(Code, References, &quot;System&quot;, &quot;Microsoft.VisualBasic.VBCodeProvider&quot;, AppDomain, FileName, CompilerOptions)
}

CLR_StartDomain(ByRef AppDomain, BaseDirectory=&quot;&quot;)
{
	static null := ComObject(13,0)
	args := ComObjArray(0xC, 5), args[0] := &quot;&quot;, args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
	AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3(&quot;CreateDomain&quot;, 0x158, null, null, args)
	return A_LastError &gt;= 0
}

CLR_StopDomain(ByRef AppDomain)
{	; ICorRuntimeHost::UnloadDomain
	DllCall(&quot;SetLastError&quot;, &quot;uint&quot;, hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), &quot;ptr&quot;, RtHst, &quot;ptr&quot;, ComObjValue(AppDomain))), AppDomain := &quot;&quot;
	return hr &gt;= 0
}

; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
CLR_Start(Version=&quot;&quot;) ; returns ICorRuntimeHost*
{
	static RtHst := 0
	; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
	; return RtHst ? RtHst : (RtHst:=COM_CreateObject(&quot;CLRMetaData.CorRuntimeHost&quot;,&quot;{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}&quot;), DllCall(NumGet(NumGet(RtHst+0)+40),&quot;uint&quot;,RtHst))
	if RtHst
		return RtHst
	EnvGet SystemRoot, SystemRoot
	if Version =
		Loop % SystemRoot &quot;\Microsoft.NET\Framework&quot; (A_PtrSize=8?&quot;64&quot;:&quot;&quot;) &quot;\*&quot;, 2
			if (FileExist(A_LoopFileFullPath &quot;\mscorlib.dll&quot;) &amp;&amp; A_LoopFileName &gt; Version)
				Version := A_LoopFileName
	if DllCall(&quot;mscoree\CorBindToRuntimeEx&quot;, &quot;wstr&quot;, Version, &quot;ptr&quot;, 0, &quot;uint&quot;, 0
	, &quot;ptr&quot;, CLR_GUID(CLSID_CorRuntimeHost, &quot;{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}&quot;)
	, &quot;ptr&quot;, CLR_GUID(IID_ICorRuntimeHost,  &quot;{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}&quot;)
	, &quot;ptr*&quot;, RtHst) &gt;= 0
		DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), &quot;ptr&quot;, RtHst) ; Start
	return RtHst
}

;
; INTERNAL FUNCTIONS
;

CLR_GetDefaultDomain()
{
	static defaultDomain := 0
	if !defaultDomain
	{	; ICorRuntimeHost::GetDefaultDomain
		if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), &quot;ptr&quot;, RtHst, &quot;ptr*&quot;, p:=0) &gt;= 0
			defaultDomain := ComObject(p), ObjRelease(p)
	}
	return defaultDomain
}

CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName=&quot;&quot;, CompilerOptions=&quot;&quot;)
{
	if !AppDomain
		AppDomain := CLR_GetDefaultDomain()
	
	if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
	|| !(codeProvider := asmProvider.CreateInstance(ProviderType))
	|| !(codeCompiler := codeProvider.CreateCompiler())
		return 0

	if !(asmSystem := (ProviderAssembly=&quot;System&quot;) ? asmProvider : CLR_LoadLibrary(&quot;System&quot;, AppDomain))
		return 0
	
	; Convert | delimited list of references into an array.
	StringSplit, Refs, References, |, %A_Space%%A_Tab%
	aRefs := ComObjArray(8, Refs0)
	Loop % Refs0
		aRefs[A_Index-1] := Refs%A_Index%
	
	; Set parameters for compiler.
	prms := CLR_CreateObject(asmSystem, &quot;System.CodeDom.Compiler.CompilerParameters&quot;, aRefs)
	, prms.OutputAssembly          := FileName
	, prms.GenerateInMemory        := FileName=&quot;&quot;
	, prms.GenerateExecutable      := SubStr(FileName,-3)=&quot;.exe&quot;
	, prms.CompilerOptions         := CompilerOptions
	, prms.IncludeDebugInformation := true
	
	; Compile!
	compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
	
	if error_count := (errors := compilerRes.Errors).Count
	{
		error_text := &quot;&quot;
		Loop % error_count
			error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? &quot;Warning &quot; : &quot;Error &quot;) . e.ErrorNumber &quot; on line &quot; e.Line &quot;: &quot; e.ErrorText &quot;`n`n&quot;
		MsgBox, 16, Compilation Failed, %error_text%
		return 0
	}
	; Success. Return Assembly object or path.
	return compilerRes[FileName=&quot;&quot; ? &quot;CompiledAssembly&quot; : &quot;PathToAssembly&quot;]
}

CLR_GUID(ByRef GUID, sGUID)
{
	VarSetCapacity(GUID, 16, 0)
	return DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;wstr&quot;, sGUID, &quot;ptr&quot;, &amp;GUID) &gt;= 0 ? &amp;GUID : &quot;&quot;
}</code></pre></div><p>Ну или на c# написать и скомпилить, но это уже сами.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-02-15T11:10:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152205#p152205</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152204#p152204" />
			<content type="html"><![CDATA[<p><a href="https://openhardwaremonitor.org/documentation/">https://openhardwaremonitor.org/documentation/</a><br /></p><div class="quotebox"><blockquote><p>The Open Hardware Monitor publishes all sensor data to WMI (Windows Management Instrumentation). This allows other applications to read and use the sensor information as well. A preliminary documentation of the interface can be found here</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-02-15T10:43:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152204#p152204</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Вывод температуры ЦПУ и ГПУ (виджет)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152202#p152202" />
			<content type="html"><![CDATA[<p>Приветствую всех!</p><p>Знаю, что есть десятки программ для отображения температуры ГПУ и ЦПУ, проблема в том, что там куча всего не нужного, нету нужного мне типа интерфейса, настроек и так далее.</p><p>Хотелось бы сделать просто вывод этих двух показаний, для начала, чтобы обновлялись ежесекундно.</p><p>Поиском пользовался - ничего похожего вообще не нашел, может это и нереально на AHK сделать, не знаю...</p><p>Заранее спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Michael]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41356</uri>
			</author>
			<updated>2022-02-15T09:00:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152202#p152202</id>
		</entry>
</feed>
