<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6477&amp;type=atom" />
	<updated>2011-11-25T18:58:21Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6477</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53859#p53859" />
			<content type="html"><![CDATA[<p>Спасибо Вам!</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-25T18:58:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53859#p53859</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53858#p53858" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>Получение пути к исполнимому файлу процесса в нем не предусмотрен?</p></blockquote></div><p>&quot;x.ExecutablePath&quot;, там же была <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394372%28v=vs.85%29.aspx">ссылка на документацию</a>.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T18:52:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53858#p53858</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53856#p53856" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Если нужна только командная строка, то в самый раз.</p></blockquote></div><p>Получение пути к исполнимому файлу процесса в нем не предусмотрен?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-25T18:30:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53856#p53856</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53855#p53855" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>Возможно, проблемы были, когда после кода точка с запятой и комментарий шли без пробела.</p></blockquote></div><p>Нет.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T17:19:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53855#p53855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53850#p53850" />
			<content type="html"><![CDATA[<p>Возможно, проблемы были, когда после кода точка с запятой и комментарий шли без пробела. Вот пример &quot;бага&quot;:<br /></p><div class="codebox"><pre><code>F1::Send,12345;Комментарий</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2011-11-25T15:45:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53850#p53850</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53847#p53847" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Хм, где это <a href="http://l.autohotkey.net/docs/Scripts.htm#Comments">указано</a>?</p></blockquote></div><p>Похоже я наврал, по крайней мере сейчас никаких заметок по этому поводу не нашёл... Я раньше часто сталкивался с багами из-за комментариев в самых разных местах, теперь пишу их только в уже готовых скриптах <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T14:53:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53847#p53847</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53846#p53846" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Лучше вообще комментарии и код на одной строчке не писать, это указано в документации.</p></blockquote></div><p>Хм, где это <a href="http://l.autohotkey.net/docs/Scripts.htm#Comments">указано</a>?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-11-25T14:20:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53846#p53846</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53844#p53844" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>Можно им удовольствоваться?</p></blockquote></div><p>Если нужна только командная строка, то в самый раз.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T13:53:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53844#p53844</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53843#p53843" />
			<content type="html"><![CDATA[<p>Как Вы находите вот такой вариант, <strong>Александр_</strong>:</p><div class="codebox"><pre><code>
F11::
WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ProcessId = &quot; . PID_Target)._NewEnum.next(x)
result := % x.CommandLine ;%
msgbox %result%
Return</code></pre></div><p>Можно им удовольствоваться?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-25T13:31:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53843#p53843</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53838#p53838" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>DD пишет:</cite><blockquote><p>А где на документированный можно глянуть? Что-то не припомню...</p></blockquote></div><p>Недавно обсуждалось на форуме. <a href="http://forum.script-coding.com/viewtopic.php?pid=52971">Тут</a> описание+ссылки на документацию, а <a href="http://forum.script-coding.com/viewtopic.php?id=6443">тут</a> пример реализации.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T12:40:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53838#p53838</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53837#p53837" />
			<content type="html"><![CDATA[<p>А где на документированный можно глянуть? Что-то не припомню...<br />Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-25T12:34:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53837#p53837</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53831#p53831" />
			<content type="html"><![CDATA[<p>Комментарии после объявления функций надо убрать. Лучше вообще комментарии и код на одной строчке не писать, это указано в документации. А вообще способ получения командной строки очень странный, учитывая наличие документированного метода. На win7 SP1 функция имеет вид &quot;jmp, jmp, mov&quot;, а на xp SP3 просто &quot;mov&quot;. Так что где-то он точно работать не будет.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-25T11:15:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53831#p53831</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Получение дополнительной инфы о процессах (Help2Ahk_L)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53818#p53818" />
			<content type="html"><![CDATA[<p>Из Коллекции скрипт.<br />Как оказалось — один из этаких краеугольных камней моего постоянно работающего.<br />Нужен в <em>AHK_L</em> виде.<br />Прошу не отказать.</p><br /><div class="codebox"><pre><code>
#SingleInstance Force

1::
WinGet, PID_Target, PID, % &quot;ahk_id &quot; WinExist(&quot;A&quot;)
result := GetRemoteCommandLine( PID_Target )
msgbox %result%
return

;*******************************************************************************
; AutoHotkey Version:   1.0.44.09+
; Автор:                Androgen Belkin
; Имя скрипта:          GetExtProccessInfo().ahk (v.1.1)
;*******************************************************************************
; Функции для:
; 1. Получения пути к исполнимому файлу процесса
; 2. Получения командной строки для процесса
; Известные ограничения:
; а) не удается получить доступ к некоторым (немногим) системным процессам,
;    в этом случае функции возвращают пустую строку
; б) функции, возможно, не будут работать в линейке WIN 9x, но я не проверял
;*******************************************************************************

;-------------------------------------------------------------------------------------------------------------
GetModuleFileNameEx( p_pid ) ; функция получения пути к исполнимому файлу процесса (по его PID&#039;у)
{
    h_process := DllCall( &quot;OpenProcess&quot;, &quot;UInt&quot;, 0x10|0x400, &quot;Int&quot;, false, &quot;UInt&quot;, p_pid ) ; открываем хэндл для PID процесса...
    ; ...с нужными правами (они понадобятся для GetModuleFileNameExA) и без наследования хэндла
    ; права: 0x10 = PROCESS_VM_READ, 0x400 = PROCESS_QUERY_INFORMATION
    If ( ErrorLevel OR h_process = 0 ) ; если почему-либо не удалось открыть хэндл (или он открыт для несуществующего PID&#039;а)...
        Goto, Return_1 ; перейти к закрытию хэндла и выйти из функции

    VarSetCapacity( pPath, 259 ) ; обеспечиваем достаточную вместимость переменной (в символах, путь длиннее не бывает)
    DllCall( &quot;psapi.dll\GetModuleFileNameExA&quot;, &quot;UInt&quot;, h_process, &quot;UInt&quot;, 0, &quot;Str&quot;, pPath, &quot;UInt&quot;, 259 ) ; получаем путь...
    ; ...для указанного хэндла процесса. GetModuleFileNameExA (ANSI), GetModuleFileNameExW (Unicode)

    Return_1: ; метка перехода к закрытию хэндла
    DllCall( &quot;CloseHandle&quot;, h_process ) ; закрываем хэндл
    Return, pPath ; возвращаем путь к файлу процесса
} ; конец функции
;-------------------------------------------------------------------------------------------------------------

;-------------------------------------------------------------------------------------------------------------
GetRemoteCommandLine( p_pid_target ) ; функция получения командной строки для процесса (по его PID&#039;у)
{
    hp_target := DllCall( &quot;OpenProcess&quot;, &quot;UInt&quot;, 0x10, &quot;Int&quot;, false, &quot;UInt&quot;, p_pid_target ) ; открываем хэндл для PID процесса...
    ; ...с правами для чтения 0x10 = PROCESS_VM_READ (нужны для ReadProcessMemory) и без наследования хэндла
    If ( ErrorLevel OR hp_target = 0 ) ; если почему-либо не удалось открыть хэндл (или он открыт для несуществующего PID&#039;а)...
        Goto, Return_2 ; перейти к закрытию хэндла и выйти из функции

    hm_kernel32 := DllCall( &quot;GetModuleHandle&quot;, &quot;Str&quot;, &quot;kernel32.dll&quot; ) ; узнаем хэндл библиотеки kernel32.dll
    pGetCommandLineA := DllCall( &quot;GetProcAddress&quot;, &quot;UInt&quot;, hm_kernel32, &quot;Str&quot;, &quot;GetCommandLineA&quot; ) ; получаем указатель...
    ; ...на адрес функции GetCommandLineA (ANSI), содержащейся в kernel32.dll

    buffer_size = 6 ; количество байт для переменной
    VarSetCapacity( buffer, buffer_size ) ; обеспечиваем достаточную вместимость переменной
    DllCall( &quot;ReadProcessMemory&quot;, &quot;UInt&quot;, hp_target, &quot;UInt&quot;, pGetCommandLineA, &quot;UInt&quot;, &amp;buffer, &quot;UInt&quot;, buffer_size, &quot;UInt&quot;, 0 )
    ; для хэндла PID&#039;а получаем перенаправление функцией GetCommandLineA на указатель на адрес командной строки...
    ; ...и кладем его по адресу &quot;buffer&quot; в памяти

    Loop, 4 ; преобразовываем указатель на адрес командной строки в целое число
        ppCommandLine += ( ( *( &amp;buffer+A_Index ) ) &lt;&lt; ( 8*( A_Index-1 ) ) ) ; создаем целое число, складывая его байты

    buffer_size = 4 ; количество байт для переменной
    VarSetCapacity( buffer, buffer_size, 0 ) ; обеспечиваем достаточную вместимость переменной, и очищаем её
    DllCall( &quot;ReadProcessMemory&quot;, &quot;UInt&quot;, hp_target, &quot;UInt&quot;, ppCommandLine, &quot;UInt&quot;, &amp;buffer, &quot;UInt&quot;, buffer_size, &quot;UInt&quot;, 0 )
    ; для хэндла PID&#039;а читаем адрес командной строки, и кладем его по адресу &quot;buffer&quot; в памяти

    Loop, 4 ; преобразовываем адрес в целое число
        pCommandLine += ( ( *( &amp;buffer+A_Index-1 ) ) &lt;&lt; ( 8*( A_Index-1 ) ) ) ; создаем целое число, складывая его байты

    ; Адрес командной строки получен, теперь извлекаем его содержимое
    buffer_size = 520 ; столько символов будем читать из командной строки (мне кажется, длиннее быть не может)
    VarSetCapacity( result, buffer_size, 1 ) ; обеспечиваем достаточную вместимость переменной, делаем её побайтной
    DllCall( &quot;ReadProcessMemory&quot;, &quot;UInt&quot;, hp_target, &quot;UInt&quot;, pCommandLine, &quot;UInt&quot;, &amp;result, &quot;UInt&quot;, buffer_size, &quot;UInt&quot;, 0 )
    ; для хэндла PID&#039;а читаем командную строку, и кладем её по адресу &quot;result&quot; в памяти (просто помещаем значение в переменную)

    Return_2: ; метка перехода к закрытию хэндла
    DllCall( &quot;CloseHandle&quot;, &quot;UInt&quot;, hp_target ) ; закрываем хэндл
    Return, result ; возвращаем полную командную строку для PID&#039;а процесса
} ; конец функции
;-------------------------------------------------------------------------------------------------------------



^!9::exitapp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-11-25T01:45:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53818#p53818</id>
		</entry>
</feed>
