<?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=17051&amp;type=atom" />
	<updated>2022-04-06T05:37:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17051</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152711#p152711" />
			<content type="html"><![CDATA[<p>comspec и cmd здесь лишние.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-04-06T05:37:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152711#p152711</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152710#p152710" />
			<content type="html"><![CDATA[<p>Через comspec у меня ничего не работает. Только через cmd:<br /></p><div class="codebox"><pre><code> MsgBox, % StdoutToVar(&quot;cmd /c quser&quot; &quot;CP&quot; DllCall(&quot;GetOEMCP&quot;, &quot;UInt&quot;))</code></pre></div><p>Но кодировка неправильная все равно.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2022-04-06T05:08:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152710#p152710</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152709#p152709" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>StdOutToVar(comspec &quot; /c quser&quot;, &quot;CP&quot; DllCall(&quot;GetOEMCP&quot;, &quot;UInt&quot;))</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-04-06T02:25:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152709#p152709</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152707#p152707" />
			<content type="html"><![CDATA[<p>А как функция вызывается?</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2022-04-06T01:13:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152707#p152707</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152706#p152706" />
			<content type="html"><![CDATA[<p>Подставил кодировку, которую получил таким методом:<br /></p><div class="codebox"><pre><code>&quot;CP&quot; DllCall(&quot;GetOEMCP&quot;, &quot;UInt&quot;)</code></pre></div><p>... и это решило проблему.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-04-05T16:56:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152706#p152706</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Проблемы с получением данных из консоли]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=152705#p152705" />
			<content type="html"><![CDATA[<p>Мне нужно выполнить команду quser. На английской винде все нормально, но на русской появляются &quot;крякозябры&quot;. Код функции:<br /></p><div class="codebox"><pre><code>StdoutToVar(sCmd, sEncoding:=&quot;CP0&quot;, sDir:=&quot;&quot;, ByRef nExitCode:=0) {
    hstdoutrd:=&quot;&quot;
	hstdoutwr:=&quot;&quot;
	nTot:=&quot;&quot;
	nSize:=&quot;&quot;
	sOutput:=&quot;&quot;
    DllCall( &quot;CreatePipe&quot;,           PtrP,hStdOutRd, PtrP,hStdOutWr, Ptr,0, UInt,0 )
    DllCall( &quot;SetHandleInformation&quot;, Ptr,hStdOutWr, UInt,1, UInt,1                 )


            VarSetCapacity( pi, (A_PtrSize == 4) ? 16 : 24,  0 )
    siSz := VarSetCapacity( si, (A_PtrSize == 4) ? 68 : 104, 0 )
    NumPut( siSz,      si,  0,                          &quot;UInt&quot; )
    NumPut( 0x100,     si,  (A_PtrSize == 4) ? 44 : 60, &quot;UInt&quot; )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 60 : 88, &quot;Ptr&quot;  )
    NumPut( hStdOutWr, si,  (A_PtrSize == 4) ? 64 : 96, &quot;Ptr&quot;  )

    If ( !DllCall( &quot;CreateProcess&quot;, Ptr,0, Ptr,&amp;sCmd, Ptr,0, Ptr,0, Int,True, UInt,0x08000000
                                  , Ptr,0, Ptr,sDir?&amp;sDir:0, Ptr,&amp;si, Ptr,&amp;pi ) )
        Return &quot;&quot;
      , DllCall( &quot;CloseHandle&quot;, Ptr,hStdOutWr )
      , DllCall( &quot;CloseHandle&quot;, Ptr,hStdOutRd )

    DllCall( &quot;CloseHandle&quot;, Ptr,hStdOutWr ) ; The write pipe must be closed before reading the stdout.
    While ( 1 )
    { ; Before reading, we check if the pipe has been written to, so we avoid freezings.
        If ( !DllCall( &quot;PeekNamedPipe&quot;, Ptr,hStdOutRd, Ptr,0, UInt,0, Ptr,0, UIntP,nTot, Ptr,0 ) )
            Break
        If ( !nTot )
        { ; If the pipe buffer is empty, sleep and continue checking.
            Sleep, 100
            Continue
        } ; Pipe buffer is not empty, so we can read it.
        VarSetCapacity(sTemp, nTot+1)
        DllCall( &quot;ReadFile&quot;, Ptr,hStdOutRd, Ptr,&amp;sTemp, UInt,nTot, PtrP,nSize, Ptr,0 )
        sOutput .= StrGet(&amp;sTemp, nSize, sEncoding)
    }

    ; * SKAN has managed the exit code through SetLastError.
    DllCall( &quot;GetExitCodeProcess&quot;, Ptr,NumGet(pi,0), UIntP,nExitCode )
    DllCall( &quot;CloseHandle&quot;,        Ptr,NumGet(pi,0)                  )
    DllCall( &quot;CloseHandle&quot;,        Ptr,NumGet(pi,A_PtrSize)          )
    DllCall( &quot;CloseHandle&quot;,        Ptr,hStdOutRd                     )
    Return sOutput
}</code></pre></div><p>В результате получаю это:<br /><span class="postimg"><img src="http://s01.geekpic.net/di-E461MB.png" alt="http://s01.geekpic.net/di-E461MB.png" /></span></p><p>Пытался указать другой &quot;sEncoding&quot;, получил это:<br /><span class="postimg"><img src="http://s01.geekpic.net/di-M0PSKQ.png" alt="http://s01.geekpic.net/di-M0PSKQ.png" /></span></p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-04-05T16:27:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=152705#p152705</id>
		</entry>
</feed>
