<?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=13929&amp;type=atom" />
	<updated>2018-07-16T10:15:45Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13929</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127098#p127098" />
			<content type="html"><![CDATA[<p><strong>svoboden</strong> - супер! Почти готовый диспетчер задач, или Process Explorer!</p>]]></content>
			<author>
				<name><![CDATA[Molotok]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39027</uri>
			</author>
			<updated>2018-07-16T10:15:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127098#p127098</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=127065#p127065" />
			<content type="html"><![CDATA[<p>В общем, вот, переделал немного, так можно отобразить все процессы в GUI с их информацией.<br /></p><div class="codebox"><pre><code>#SingleInstance Ignore

full_command_line := DllCall(&quot;GetCommandLine&quot;, &quot;str&quot;)
if not (A_IsAdmin or RegExMatch(full_command_line, &quot; /restart(?!\S)&quot;))
{
  try
  {
    if A_IsCompiled
      RunWait *RunAs &quot;%A_ScriptFullPath%&quot; /restart
    else
      RunWait *RunAs &quot;%A_AhkPath%&quot; /restart &quot;%A_ScriptFullPath%&quot;
  }
}
if not A_IsAdmin
{
  MsgBox,Administrator rights not found, the program might not work correctly.
}

Gui, New, -DPIScale
Gui, Add, ListView, x0 y0 w%A_ScreenWidth% h480, CreationClassName|Caption|CommandLine|CreationDate|CSCreationClassName|CSName|Description|ExecutablePath|ExecutionState|Handle|HandleCount|InstallDate|KernelModeTime|MaximumWorkingSetSize|MinimumWorkingSetSize|Name|OSCreationClassName|OSName|OtherOperationCount|OtherTransferCount|PageFaults|PageFileUsage|ParentProcessId|PeakPageFileUsage|PeakVirtualSize|PeakWorkingSetSize|Priority|PrivatePageCount|ProcessId|QuotaNonPagedPoolUsage|QuotaPagedPoolUsage|QuotaPeakNonPagedPoolUsage|QuotaPeakPagedPoolUsage|ReadOperationCount|ReadTransferCount|SessionId|Status|TerminationDate|ThreadCount|UserModeTime|VirtualSize|WindowsVersion|WorkingSetSize|WriteOperationCount|WriteTransferCount|Legal Info

for process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process&quot;)
    LV_Add(&quot;&quot;, process.Handle, process.Caption, process.CommandLine, process.CreationDate, process.CSCreationClassName, process.CSName, process.Description, process.ExecutablePath, process.ExecutionState, process.Handle, process.HandleCount, process.InstallDate, process.KernelModeTime, process.MaximumWorkingSetSize, process.MinimumWorkingSetSize, process.Name, process.OSCreationClassName, process.OSName, process.OtherOperationCount, process.OtherTransferCount, process.PageFaults, process.PageFileUsage, process.ParentProcessId, process.PeakPageFileUsage, process.PeakVirtualSize, process.PeakWorkingSetSize, process.Priority, process.PrivatePageCount, process.ProcessId, process.QuotaNonPagedPoolUsage, process.QuotaPagedPoolUsage, process.QuotaPeakNonPagedPoolUsage, process.QuotaPeakPagedPoolUsage, process.ReadOperationCount, process.ReadTransferCount, process.SessionId, process.Status, process.TerminationDate, process.ThreadCount, process.UserModeTime, process.VirtualSize, process.WindowsVersion, process.WorkingSetSize, process.WriteOperationCount, process.WriteTransferCount)
LV_ModifyCol()
Gui, Show,, Process List
return

GuiClose:
ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2018-07-14T19:15:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=127065#p127065</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126926#p126926" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Molotok пишет:</cite><blockquote><p>Читал и использовал</p></blockquote></div><p>Ну, если бы читали до конца, то либо такой вопрос не задали бы, либо иначе сформулировали, т. к. аккурат в конце этой статьи данная тема и рассматривается.</p><p>Хотя приведённый выше код даже лучше, вроде бы.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-07-10T20:14:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126926#p126926</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126925#p126925" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p><strong>Molotok</strong>, почитайте для начала справку по команде Process.</p></blockquote></div><p>Читал и использовал. Команда Process много чего не умеет.</p><p><strong>svoboden, powercat</strong> - спасибо за код. Особенно полезен первый скрипт. С его помощью можно вытащить PID каждого процесса в списке. Даже когда много процессов с одним именем.</p>]]></content>
			<author>
				<name><![CDATA[Molotok]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39027</uri>
			</author>
			<updated>2018-07-10T20:09:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126925#p126925</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126922#p126922" />
			<content type="html"><![CDATA[<p>Вот.<br /></p><div class="codebox"><pre><code>#NoEnv
#SingleInstance Force
SetBatchLines -1

MsgBox % WTSEnumProcesses( Mode := 2 ) ; Mode 0 - только PID, 1 PID + имя процесса, 2 только имя процесса

WTSEnumProcesses( Mode := 1 ) { ;        By SKAN,  http://goo.gl/6Zwnwu,  CD:24/Aug/2014 | MD:25/Aug/2014 
	Local tPtr := 0, pPtr := 0, nTTL := 0, LIST := &quot;&quot;
	
	If not DllCall( &quot;Wtsapi32\WTSEnumerateProcesses&quot;, &quot;Ptr&quot;,0, &quot;Int&quot;,0, &quot;Int&quot;,1, &quot;PtrP&quot;,pPtr, &quot;PtrP&quot;,nTTL )
		Return &quot;&quot;, DllCall( &quot;SetLastError&quot;, &quot;Int&quot;,-1 )        
	
	tPtr := pPtr
	Loop % ( nTTL ) 
		LIST .= ( Mode &lt; 2 ? NumGet( tPtr + 4, &quot;UInt&quot; ) : &quot;&quot; )           ; PID
         .  ( Mode = 1 ? A_Tab : &quot;&quot; )
         .  ( Mode &gt; 0 ? StrGet( NumGet( tPtr + 8 ) ) &quot;`n&quot; : &quot;,&quot; )   ; Process name  
  , tPtr += ( A_PtrSize = 4 ? 16 : 24 )                              ; sizeof( WTS_PROCESS_INFO )  
	
	StringTrimRight, LIST, LIST, 1
	DllCall( &quot;Wtsapi32\WTSFreeMemory&quot;, &quot;Ptr&quot;,pPtr )      
	
	Return LIST, DllCall( &quot;SetLastError&quot;, &quot;UInt&quot;,nTTL ) 
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[powercat]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=37884</uri>
			</author>
			<updated>2018-07-10T18:34:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126922#p126922</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126921#p126921" />
			<content type="html"><![CDATA[<p>Так можно получить список, путь к процессам, и кое-какую информацию о процессах:<br /></p><div class="codebox"><pre><code>#NoEnv
#SingleInstance Force
SetBatchLines -1

AccessRights_EnableSeDebug()

OUT_LIST := &quot;&quot;, COUNT_NO_PATHS := 0
for i, v in WTSEnumerateProcessesEx()
{
    FullEXEPath := GetModuleFileNameEx( v.ProsessID )
    OUT_LIST := OUT_LIST . &quot;Name: &quot; . v.ProcessName . &quot;`nPath: &quot; . FullEXEPath . &quot;`nLegal: &quot; .  FileGetInfo( FullEXEPath ).LegalCopyright . &quot;`n`n&quot;
}
Clipboard := OUT_LIST
msgbox % OUT_LIST
return

; ==============================================================
; WTSEnumerateProcessesEx() By JNIZM - https://autohotkey.com/boards/viewtopic.php?t=19323
;==============================================================

Return
WTSEnumerateProcessesEx()
{
    static hWTSAPI := DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;wtsapi32.dll&quot;, &quot;ptr&quot;)

    if !(DllCall(&quot;wtsapi32\WTSEnumerateProcessesEx&quot;, &quot;ptr&quot;, 0, &quot;uint*&quot;, 0, &quot;uint&quot;, -2, &quot;ptr*&quot;, buf, &quot;uint*&quot;, TTL))
        throw Exception(&quot;WTSEnumerateProcessesEx failed&quot;, -1)
    addr := buf, WTS_PROCESS_INFO := []
    loop % TTL
    {
        WTS_PROCESS_INFO[A_Index, &quot;SessionID&quot;]   := NumGet(addr+0, &quot;uint&quot;)
        WTS_PROCESS_INFO[A_Index, &quot;ProsessID&quot;]   := NumGet(addr+4, &quot;uint&quot;)
        WTS_PROCESS_INFO[A_Index, &quot;ProcessName&quot;] := StrGet(NumGet(addr+8, &quot;ptr&quot;))
        WTS_PROCESS_INFO[A_Index, &quot;UserSID&quot;]     := NumGet(addr+8+A_PtrSize, &quot;ptr&quot;)
        addr += 8 + (A_PtrSize * 2)
    }
    if !(DllCall(&quot;wtsapi32\WTSFreeMemoryEx&quot;, &quot;int&quot;, 0, &quot;ptr&quot;, buf, &quot;uint&quot;, TTL))
        throw Exception(&quot;WTSFreeMemoryEx failed&quot;, -1)
    return WTS_PROCESS_INFO
}

Return

; ==================================================
; FileGetInfo() By Lexikos - https://autohotkey.com/boards/viewtopic.php?t=4282
;===================================================

FileGetInfo( lptstrFilename) {
	List := &quot;Comments InternalName ProductName CompanyName LegalCopyright ProductVersion&quot;
		. &quot; FileDescription LegalTrademarks PrivateBuild FileVersion OriginalFilename SpecialBuild&quot;
	dwLen := DllCall(&quot;Version.dll\GetFileVersionInfoSize&quot;, &quot;Str&quot;, lptstrFilename, &quot;Ptr&quot;, 0)
	dwLen := VarSetCapacity( lpData, dwLen + A_PtrSize)
	DllCall(&quot;Version.dll\GetFileVersionInfo&quot;, &quot;Str&quot;, lptstrFilename, &quot;UInt&quot;, 0, &quot;UInt&quot;, dwLen, &quot;Ptr&quot;, &amp;lpData) 
	DllCall(&quot;Version.dll\VerQueryValue&quot;, &quot;Ptr&quot;, &amp;lpData, &quot;Str&quot;, &quot;\VarFileInfo\Translation&quot;, &quot;PtrP&quot;, lplpBuffer, &quot;PtrP&quot;, puLen )
	sLangCP := Format(&quot;{:04X}{:04X}&quot;, NumGet(lplpBuffer+0, &quot;UShort&quot;), NumGet(lplpBuffer+2, &quot;UShort&quot;))
	i := {}
	Loop, Parse, % List, %A_Space%
		DllCall(&quot;Version.dll\VerQueryValue&quot;, &quot;Ptr&quot;, &amp;lpData, &quot;Str&quot;, &quot;\StringFileInfo\&quot; sLangCp &quot;\&quot; A_LoopField, &quot;PtrP&quot;, lplpBuffer, &quot;PtrP&quot;, puLen )
		? i[A_LoopField] := StrGet(lplpBuffer, puLen) : &quot;&quot;
	return i
}

Return

; =================================================================================================
; GetModuleFileNameEx() By Shimanov as cited by SKAN - https://autohotkey.com/board/topic/41197-getting-a-full-executable-path-from-a-running-process/
; Modified to use GetModuleFileNameExW if A_IsUnicode - By Gio - 03-11-17
;=================================================================================================

GetModuleFileNameEx( p_pid ) ; by shimanov -  www.autohotkey.com/forum/viewtopic.php?t=9000
{
   if A_OSVersion in WIN_95,WIN_98,WIN_ME
   {
      MsgBox, This Windows version (%A_OSVersion%) is not supported.
      return
   }
   h_process := DllCall( &quot;OpenProcess&quot;, &quot;uint&quot;, 0x10|0x400, &quot;int&quot;, false, &quot;uint&quot;, p_pid )
   if ( ErrorLevel or h_process = 0 )
      return
   name_size = 255
   VarSetCapacity( name, name_size )
   If A_IsUnicode
      result := DllCall( &quot;psapi.dll\GetModuleFileNameExW&quot;, &quot;uint&quot;, h_process, &quot;uint&quot;, 0, &quot;str&quot; , name, &quot;uint&quot;, name_size )
    Else
      result := DllCall( &quot;psapi.dll\GetModuleFileNameExA&quot;, &quot;uint&quot;, h_process, &quot;uint&quot;, 0, &quot;str&quot; , name, &quot;uint&quot;, name_size )
   DllCall( &quot;CloseHandle&quot;, h_process )
   return, name
}

; =================================================================================================
; AccessRights_EnableSeDebug() By Cyruz - https://autohotkey.com/boards/viewtopic.php?t=2039
;=================================================================================================
; ----------------------------------------------------------------------------------------------------------------------
; Function .....: AccessRights_EnableSeDebug
; Description ..: Enable the SE_DEBUG_PRIVILEGE on the current script instance.
; AHK Version ..: AHK_L x32/64 Unicode
; Author .......: Cyruz - http://ciroprincipe.info
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog ....: Feb. 5, 2014 - v0.1 - First version.
; ----------------------------------------------------------------------------------------------------------------------
AccessRights_EnableSeDebug() {
	hProc := DllCall( &quot;OpenProcess&quot;, UInt,0x0400, Int,0, UInt,DllCall(&quot;GetCurrentProcessId&quot;), &quot;Ptr&quot; )
	DllCall( &quot;Advapi32.dll\OpenProcessToken&quot;, Ptr,hProc, UInt,0x0020|0x0008, PtrP,hToken )

	VarSetCapacity(LUID, 8, 0)
	DllCall( &quot;Advapi32.dll\LookupPrivilegeValue&quot;, Ptr,0, Str,&quot;SeDebugPrivilege&quot;, Ptr,&amp;LUID )

	VarSetCapacity( TOKPRIV, 16, 0   )					      ; TOKEN_PRIVILEGES structure: http://goo.gl/AGXeAp.
	NumPut( 1, &amp;TOKPRIV, 0,   &quot;UInt&quot; )                        ; TOKEN_PRIVILEGES &gt; PrivilegeCount.
	NumPut( NumGet( &amp;LUID, 0, &quot;UInt&quot; ), &amp;TOKPRIV, 4, &quot;UInt&quot; ) ; TOKEN_PRIVILEGES &gt; LUID_AND_ATTRIBUTES &gt; LUID &gt; LoPart.
	NumPut( NumGet( &amp;LUID, 4, &quot;UInt&quot; ), &amp;TOKPRIV, 8, &quot;UInt&quot; ) ; TOKEN_PRIVILEGES &gt; LUID_AND_ATTRIBUTES &gt; LUID &gt; HiPart.
	NumPut( 2, &amp;TOKPRIV, 12,  &quot;UInt&quot; )                        ; TOKEN_PRIVILEGES &gt; LUID_AND_ATTRIBUTES &gt; Attributes.
														      ; SE_PRIVILEGE_ENABLED = 2.

	DllCall( &quot;Advapi32.dll\AdjustTokenPrivileges&quot;, Ptr,hToken, Int,0, Ptr,&amp;TOKPRIV, UInt,0, Ptr,0, Ptr,0 )
    DllCall( &quot;CloseHandle&quot;, Ptr,hToken )
    DllCall( &quot;CloseHandle&quot;, Ptr,hProc  )
}</code></pre></div><p>Правда, в Msgbox все процессы не вмещаются, но они копируются в буфер обмена.<br />И чтобы отображались пути к системные процессам, от администратора запускайте скрипт.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2018-07-10T18:02:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126921#p126921</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126919#p126919" />
			<content type="html"><![CDATA[<p><strong>Molotok</strong>, почитайте для начала справку по команде Process.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-07-10T16:55:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126919#p126919</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Получить полный список запущенных процессов.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=126917#p126917" />
			<content type="html"><![CDATA[<p>Привет народ. Как можно получить полный список запущенных процессов?<br />Желательно не обращаться к командной строке.<br />Полная информация о процессах тоже лишней не будет. (<a href="http://forum.script-coding.com/viewtopic.php?id=174">Эту </a>тему видел)</p>]]></content>
			<author>
				<name><![CDATA[Molotok]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39027</uri>
			</author>
			<updated>2018-07-10T16:40:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=126917#p126917</id>
		</entry>
</feed>
