Deutsches AutoHotkey Homepage AutoHotkey Community
Wir helfen uns gegenseitig aus der Patsche
 
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

Laufende Prozesse in ListView anzeigen

 
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe!
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
Dbof



Anmeldedatum: 10.01.2008
Beiträge: 282
Wohnort: C:\

BeitragVerfasst am: Di Jan 22, 2008 6:36 pm    Titel: Laufende Prozesse in ListView anzeigen Antworten mit Zitat

Weiß jemand, wie man die laufenden Prozesse in eine eigene ListView einbringen kann? So wie der Task Manager von Windows.

Moderator AGermanUser: Thread verschoben, Betreff geändert
_________________
mein spontanes ControlSend - Tutorial:

http://de.autohotkey.com/forum/viewtopic.php?p=25173#25173
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Obi-Wahn



Anmeldedatum: 19.04.2006
Beiträge: 651
Wohnort: Wien

BeitragVerfasst am: Di Jan 22, 2008 6:43 pm    Titel: Antworten mit Zitat

Ein banaler weg währe über cmd.exe und dem befehl "tasklist", welcher standardmäßig bei @ least xp home/pro (zumindest bei mir) integriert sein sollte.

danach per loop, parse und LV_Add hinzufügen.
_________________
Garten ist eine Kunstnatur
Das Leben ist nicht fair. Es ist nur fairer als der Tod, das ist alles.
Obi-Wahns Codeschnipsel @ securityvision.ch
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
DerRaphael



Anmeldedatum: 09.01.2008
Beiträge: 1037
Wohnort: Zuhause

BeitragVerfasst am: Di Jan 22, 2008 6:44 pm    Titel: Antworten mit Zitat

aus der engl Hilfe (Thema Process)

Zitat:
Code:
; Example #4: Retrieves a list of running processes via DllCall then shows them in a MsgBox.

d = `n  ; string separator
s := 4096  ; size of buffers and arrays (4 KB)

Process, Exist  ; sets ErrorLevel to the PID of this running script
; Get the handle of this script with PROCESS_QUERY_INFORMATION (0x0400)
h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel)
; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
DllCall("Advapi32.dll\OpenProcessToken", "UInt", h, "UInt", 32, "UIntP", t)
VarSetCapacity(ti, 16, 0)  ; structure of privileges
NumPut(1, ti, 0, 4)  ; one entry in the privileges array...
; Retrieves the locally unique identifier of the debug privilege:
DllCall("Advapi32.dll\LookupPrivilegeValueA", "UInt", 0, "Str", "SeDebugPrivilege", "UIntP", luid)
NumPut(luid, ti, 4, 8)
NumPut(2, ti, 12, 4)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
; Update the privileges of this process with the new access token:
DllCall("Advapi32.dll\AdjustTokenPrivileges", "UInt", t, "Int", false, "UInt", &ti, "UInt", 0, "UInt", 0, "UInt", 0)
DllCall("CloseHandle", "UInt", h)  ; close this process handle to save memory

hModule := DllCall("LoadLibrary", "Str", "Psapi.dll")  ; increase performance by preloading the libaray
s := VarSetCapacity(a, s)  ; an array that receives the list of process identifiers:
DllCall("Psapi.dll\EnumProcesses", "UInt", &a, "UInt", s, "UIntP", r)
Loop, % r // 4  ; parse array for identifiers as DWORDs (32 bits):
{
   id := NumGet(a, A_Index * 4)
   ; Open process with: PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)
   h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id)
   VarSetCapacity(m, s)  ; an array that receives the list of module handles:
   DllCall("Psapi.dll\EnumProcessModules", "UInt", h, "UInt", &m, "UInt", s, "UIntP", r)
   VarSetCapacity(n, s, 0)  ; a buffer that receives the base name of the module:
   e := DllCall("Psapi.dll\GetModuleBaseNameA", "UInt", h, "UInt", m, "Str", n, "Chr", s)
   DllCall("CloseHandle", "UInt", h)  ; close process handle to save memory
   If n  ; if image is not null add to list:
      l = %l%%n%%d%
}
DllCall("FreeLibrary", "UInt", hModule)  ; unload the library to free memory
; Remove the first and last items in the list (possibly ASCII signitures)
StringMid, l, l, InStr(l, d) + 1, InStr(l, d, false, 0) - 2 - InStr(l, d)
StringReplace, l, l, %d%, %d%, UseErrorLevel  ; gets the number of processes
;Sort, l, C  ; uncomment this line to sort the list alphabetically
MsgBox, 0, %ErrorLevel% Processes, %l%


das was inder msgbox steht, musst du nur in eine eigene ListView verfrachten

grüße
derRaphael
_________________
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1878
Wohnort: Österreich

BeitragVerfasst am: Di Jan 22, 2008 8:34 pm    Titel: Antworten mit Zitat

Ich habe mal hier meinen Taskmanager hochgeladen soweit ich ihn geschrieben habe bisher (zwei Abende):
http://www.autohotkey.net/~Thalon/Diverses/TaskManager.zip

Das Zip enthält alles was benötigt wird, inklusive einem Project-File für PSPad.

Thalon
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Dbof



Anmeldedatum: 10.01.2008
Beiträge: 282
Wohnort: C:\

BeitragVerfasst am: Di Jan 22, 2008 10:00 pm    Titel: Antworten mit Zitat

Thalon, danke für dein Script, aber ich glaube nicht, dass ich was damit anfangen kann, ist sehr schwer geschrieben, und ich bin ein kleiner Anfänger:D

Aber vll. kannst du mir erklären, wie ich die Liste in eine Listview bekomme.Ich wollte es eig. so machen, dass ich die Prozesse in einer Textdatei speichere und dann so einlese, dass sie zur ListView hinzugefügt werden. Diese werden mit Loop, Read gelesen. Das klappt auch wunderbar, aber kann man das auch alles in Variablen speichern? Ich hab es so versucht, jedoch wird dann nur 1 Eintrag erstellt, und die ganzen Prozesse werden in einer Zeile aufgelistet, durch ein Zeichen getrennt.

Code:

; Example #4: Retrieves a list of running processes via DllCall then shows them in a MsgBox.


d = `n  ; string separator
s := 4096  ; size of buffers and arrays (4 KB)

Process, Exist  ; sets ErrorLevel to the PID of this running script
; Get the handle of this script with PROCESS_QUERY_INFORMATION (0x0400)
h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel)
; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
DllCall("Advapi32.dll\OpenProcessToken", "UInt", h, "UInt", 32, "UIntP", t)
VarSetCapacity(ti, 16, 0)  ; structure of privileges
NumPut(1, ti, 0, 4)  ; one entry in the privileges array...
; Retrieves the locally unique identifier of the debug privilege:
DllCall("Advapi32.dll\LookupPrivilegeValueA", "UInt", 0, "Str", "SeDebugPrivilege", "UIntP", luid)
NumPut(luid, ti, 4, 8)
NumPut(2, ti, 12, 4)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
; Update the privileges of this process with the new access token:
DllCall("Advapi32.dll\AdjustTokenPrivileges", "UInt", t, "Int", false, "UInt", &ti, "UInt", 0, "UInt", 0, "UInt", 0)
DllCall("CloseHandle", "UInt", h)  ; close this process handle to save memory

hModule := DllCall("LoadLibrary", "Str", "Psapi.dll")  ; increase performance by preloading the libaray
s := VarSetCapacity(a, s)  ; an array that receives the list of process identifiers:
DllCall("Psapi.dll\EnumProcesses", "UInt", &a, "UInt", s, "UIntP", r)
Loop, % r // 4  ; parse array for identifiers as DWORDs (32 bits):
{
   id := NumGet(a, A_Index * 4)
   ; Open process with: PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)
   h := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", id)
   VarSetCapacity(m, s)  ; an array that receives the list of module handles:
   DllCall("Psapi.dll\EnumProcessModules", "UInt", h, "UInt", &m, "UInt", s, "UIntP", r)
   VarSetCapacity(n, s, 0)  ; a buffer that receives the base name of the module:
   e := DllCall("Psapi.dll\GetModuleBaseNameA", "UInt", h, "UInt", m, "Str", n, "Chr", s)
   DllCall("CloseHandle", "UInt", h)  ; close process handle to save memory
   If n  ; if image is not null add to list:
      l = %l%%n%%d%
}
DllCall("FreeLibrary", "UInt", hModule)  ; unload the library to free memory
; Remove the first and last items in the list (possibly ASCII signitures)
StringMid, l, l, InStr(l, d) + 1, InStr(l, d, false, 0) - 2 - InStr(l, d)
StringReplace, l, l, %d%, %d%, UseErrorLevel  ; gets the number of processes
;Sort, l, C  ; uncomment this line to sort the list alphabetically



Gui, Add, Listview, , 1|2|3|4


LV_Add("", l)

Gui, Show



Hier der Code...Kann ich alles in einem ListView auflisten oder brauche ich eine Textdatei?
_________________
mein spontanes ControlSend - Tutorial:

http://de.autohotkey.com/forum/viewtopic.php?p=25173#25173
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
DerRaphael



Anmeldedatum: 09.01.2008
Beiträge: 1037
Wohnort: Zuhause

BeitragVerfasst am: Di Jan 22, 2008 10:53 pm    Titel: Antworten mit Zitat

ich denke mal, dass du dir dem umweg über die txt datei sparen kannst.

was du benötigst ist in diesem fall der befehl Loop, Parse
wobei als Delimiter `n und als Ommit `r in Frage kommen
den jagstdu über die ausgabe des demoscripts (die variable l)

viel spaß beim experimentieren
grüße
derRaphael
_________________
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden
Thalon



Anmeldedatum: 25.10.2005
Beiträge: 1878
Wohnort: Österreich

BeitragVerfasst am: Di Jan 22, 2008 11:52 pm    Titel: Antworten mit Zitat

Hallo Dbof,

Habe das Skript mal etwas abgespeckt für dich. Das ruft einmal die laufenden Prozesse ab wenn das Skript gestartet wird.

Es bestimmt alle laufenden Prozesse und liest den Namen aus.
Im vorderen Teil setzt es die eigenen Rechte hoch auf "priviligiert", ansonsten kann es andere priviligierte nicht lesen und liefert nur Kauderwelch zurück.

Der Systemprozess und Leerlauf haben fixe PIDs und der Name ist nicht in der Instanz eingetragen, deshalb weise ich diesen bei den IFs manuell zu.
Code:
B_A_Size := 4096  ; size of buffers and arrays (4 KB)

Gui, Add, ListView, x10 y10 r60 w400 section Sort vProcesslist, Name
Gui, Show, , Prozessliste
hModule := DllCall("LoadLibrary", "Str", "Psapi.dll")  ; increase performance by preloading the library

/*
   Set's the script to be a privileged process (required to get infos from other privileged processes!)
*/
Process, Exist  ; sets ErrorLevel to the PID of this running script
; Get the handle of this script with PROCESS_QUERY_INFORMATION (0x0400)
h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", ErrorLevel)
; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
DllCall("Advapi32.dll\OpenProcessToken", "UInt", h, "UInt", 32, "UIntP", t)
VarSetCapacity(ti, 16, 0)  ; structure of privileges
NumPut(1, ti, 0, 4)  ; one entry in the privileges array...
; Retrieves the locally unique identifier of the debug privilege:
DllCall("Advapi32.dll\LookupPrivilegeValueA", "UInt", 0, "Str", "SeDebugPrivilege", "UIntP", luid)
NumPut(luid, ti, 4, 8)
NumPut(2, ti, 12, 4)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
; Update the privileges of this process with the new access token:
DllCall("Advapi32.dll\AdjustTokenPrivileges", "UInt", t, "Int", false, "UInt", &ti, "UInt", 0, "UInt", 0, "UInt", 0)
DllCall("CloseHandle", "UInt", h)  ; close this process handle to save memory

B_A_Size := VarSetCapacity(ProcessIDs, B_A_Size, 0)  ; an array that receives the list of process identifiers:
DllCall("Psapi.dll\EnumProcesses", "UInt", &ProcessIDs, "UInt", B_A_Size, "UIntP", BytesReturned)

Loop, % BytesReturned // 4  ; parse array for identifiers as DWORDs (32 bits):
{
   P_ID := NumGet(ProcessIDs, A_Index * 4)

   P_Handle := DllCall("OpenProcess"
          , "UInt", 0x0010 | 0x0400   ;PROCESS_VM_READ (0x0010) | PROCESS_QUERY_INFORMATION (0x0400)
         , "Int", false
         , "UInt", P_ID)
         
   VarSetCapacity(ModuleHandle, B_A_Size)  ; an array that receives the list of module handles:
   DllCall("Psapi.dll\EnumProcessModules"
         , "UInt", P_Handle
         , "UInt", &ModuleHandle
         , "UInt", B_A_Size
         , "UIntP", BytesReturned)
         
   VarSetCapacity(Processname, B_A_Size, 0)  ; a buffer that receives the base name of the module:
   Success := DllCall("Psapi.dll\GetModuleBaseNameA"
      , "UInt", P_Handle
      , "UInt", ModuleHandle
      , "Str", Processname
      , "Chr", B_A_Size)
   if !Success
      Processname = Unknown
      

   DllCall("CloseHandle", "UInt", P_Handle)  ; close process handle to save memory

   If Processname  ; if image is not null add to list:
   {
      if P_ID = 0      ;PID 0 is always the "System Idle Process"
         Processname = Idletask
      else if (P_ID = "2") AND (A_OSVersion = "WIN_NT4")      ;On NT 4 PID 2 is the "System Process"
         Processname = Systemprocess
      else if (P_ID = "4") AND ((A_OSVersion = "WIN_2000") OR (A_OSVersion = "WIN_XP") OR (A_OSVersion = "WIN_VISTA"))      ;On Win2K PID 4 is the "System Process"
         Processname = Systemprocess

      LV_Add("", Processname)
   }

}
return

GuiClose:
ExitApp
Falls noch weitere Fragen sind einfach hier stellen...
_________________
Mein Motto: Hilfe zur Selbsthilfe!
Teildeutsche Hilfe (CHM)!! und Deutsche Online-Hilfe
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe! Alle Zeiten sind GMT
Seite 1 von 1

 
Gehe zu:  
Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.


Powered by phpBB © 2001, 2005 phpBB Group
Deutsche Übersetzung von phpBB.de