<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Проблемы с получением данных из консоли]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17051</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17051&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Проблемы с получением данных из консоли».]]></description>
		<lastBuildDate>Wed, 06 Apr 2022 05:37:48 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152711#p152711</link>
			<description><![CDATA[<p>comspec и cmd здесь лишние.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 06 Apr 2022 05:37:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152711#p152711</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152710#p152710</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (svoboden)]]></author>
			<pubDate>Wed, 06 Apr 2022 05:08:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152710#p152710</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152709#p152709</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Wed, 06 Apr 2022 02:25:39 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152709#p152709</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152707#p152707</link>
			<description><![CDATA[<p>А как функция вызывается?</p>]]></description>
			<author><![CDATA[null@example.com (svoboden)]]></author>
			<pubDate>Wed, 06 Apr 2022 01:13:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152707#p152707</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152706#p152706</link>
			<description><![CDATA[<p>Подставил кодировку, которую получил таким методом:<br /></p><div class="codebox"><pre><code>&quot;CP&quot; DllCall(&quot;GetOEMCP&quot;, &quot;UInt&quot;)</code></pre></div><p>... и это решило проблему.</p>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Tue, 05 Apr 2022 16:56:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152706#p152706</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Проблемы с получением данных из консоли]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=152705#p152705</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Phoenixxx_Czar)]]></author>
			<pubDate>Tue, 05 Apr 2022 16:27:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=152705#p152705</guid>
		</item>
	</channel>
</rss>
