Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 11:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Aus dem Process den Handle bzw Titel rausfinden.

Discussion on Aus dem Process den Handle bzw Titel rausfinden. within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2010
Posts: 210
Received Thanks: 45
Exclamation Aus dem Process den Handle bzw Titel rausfinden.

Hallo alle zusammen,
ich möchte mit dem Processnamen den Handle rausfinden dem man normalerweiße mit WinGetHandle findet ,jedoch braucht man dfür den Title,
es ist mir egal ob wir erst den Title finden und dann den Handle finden oder opb wir ihn direkt finden ...

Danke schön
Lighthex is offline  
Old 11/15/2010, 17:19   #2
 
omer36's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 2,317
Received Thanks: 1,254
und was genau ist jetz an den Title so schwer abzulesen/auslesen zu lassen? o.O
oder habe ich das grade nicht kapiert?!
omer36 is offline  
Old 11/15/2010, 18:27   #3
 
elite*gold: 0
Join Date: Sep 2010
Posts: 210
Received Thanks: 45
Also ich werde in einer Liste die Processe anzeigen lassen und dann soll das Programm über den Processnamen den Title oder den Handle kriegen ...
Wie kan ich das umsetzten es gibt ja kein
ProcesGetHandle
Lighthex is offline  
Old 11/15/2010, 19:32   #4
 
amnesi's Avatar
 
elite*gold: 25
Join Date: Jun 2010
Posts: 1,076
Received Thanks: 290
Ja aber in dem Prozessen steht z.b. Mozilla.exe
Und diese .exe startet den Browser.
Es wird schwierig aus der Exe das Winhandle/Wintitle rauszekriegen
amnesi is offline  
Old 11/15/2010, 19:47   #5
 
elite*gold: 0
Join Date: Sep 2010
Posts: 210
Received Thanks: 45
Hat sonst wer ne Idee
Lighthex is offline  
Old 11/15/2010, 19:48   #6
 
.BritainAndy's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 1,385
Received Thanks: 1,006
Quote:
Originally Posted by amnesi View Post
Ja aber in dem Prozessen steht z.b. Mozilla.exe
Und diese .exe startet den Browser.
ah, und so soll man deiner meinung nach den handle/ fenster title rauskriegen?
.BritainAndy is offline  
Old 11/15/2010, 19:57   #7
 
elite*gold: 0
Join Date: Nov 2010
Posts: 6
Received Thanks: 3
Code:
$Test = _ProcessGetWindows("firefox.exe")

If Not @error Then
    For $t = 1 To $Test[0][0]
        MsgBox(0, "", "Fenstertitel " & $t & ":" & @CRLF & @CRLF & $Test[$t][0])
    Next
EndIf

#cs
    Return an 2Dim-Array of all visible Windows of a Process and is made up follows:
    The array returned is two-dimensional and is made up as follows:
    $array[0][0] = Number of windows returned
    $array[1][0] = 1st window title
    $array[1][1] = 1st window handle (HWND)
    $array[2][0] = 2nd window title
    $array[2][1] = 2nd window handle (HWND)
    ...
    $array[n][0] = nth window title
    $array[n][1] = nth window handle (HWND)
#ce
Func _ProcessGetWindows($PID)
    Local $WList = WinList()
    Local $RArr[1][2]
    
    If Not ProcessExists($PID) Then Return SetError(2, 2, $RArr)
    
    If IsString($PID) Then
        Local $PList = ProcessList($PID)
        If Not @error Then $PID = $PList[1][1]
    EndIf
    
    For $i = 1 To $WList[0][0]
        If WinGetProcess($WList[$i][0]) = $PID Then
            If BitAND(WinGetState($WList[$i][1]), 2) Then
                $RArr[0][0] += 1
                ReDim $RArr[$RArr[0][0] + 1][2]
                $RArr[$RArr[0][0]][0] = $WList[$i][0]
                $RArr[$RArr[0][0]][1] = $WList[$i][1]
            EndIf
        EndIf
    Next
    If $RArr[0][0] = 0 Then Return SetError(1, 1, $RArr)
    Return $RArr
EndFunc
Die Funktion wurde von AspirinJunkie (autoit.de) erstellt
Fab1an is offline  
Old 11/15/2010, 19:59   #8
 
bollen's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 221
Received Thanks: 71
Mit
Code:
ProcessList("NAME")
kannst du dir die Prozesse auflisten lassen,
wenn du kein Name angibst Zeigt er alle Prozesse in einm
araay an
Code:
$array[0][0] = Anzahl der Prozesse
$array[1][0] = Name des 1. Prozesses
$array[1][1] = Process ID (PID) des 1. Prozesses
$array[2][0] = Name des 2. Prozesses
$array[2][1] = Process ID (PID) des 2. Prozesses
und dann ist es einfach den richtigen Prozess zu finden
€ Ähnlich wie oben
bollen is offline  
Old 11/15/2010, 20:34   #9
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
da ein prozess n guis haben kann (n>=0), ist es nicht möglich einem prozess ein fenster zuzuordnen...

du könntest dir aber zu jedem prozess ein fenster suchen, bzw alle anzeigen lassen, mit einer combination aus winlist, processlist und wingetprocess
lolkop is offline  
Old 11/15/2010, 22:24   #10
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Hier mal mein Ansatz:

Code:
#include <Array.au3>

$ahWnd = _HwndByProcessName("iexplore.exe")
_ArrayDisplay($ahWnd)

Func _HwndByProcessName($sProcess)
	Local $iPId = 0, $aPId[1], $aResult
	$aProc = ProcessList()
	For $i = 1 To $aProc[0][0]
		If $aProc[$i][0] = $sProcess Then
			$iPId = $aProc[$i][1]
			ExitLoop
		EndIf
	Next
	$aWin = WinList()
	$User32 = DllOpen("user32.dll")
	For $i = 1 To $aWin[0][0]
		$aResult = DllCall($User32, "dword", "GetWindowThreadProcessId", "hwnd", $aWin[$i][1], "dword*", 0)
		If $aResult[2] = $iPId Then _ArrayAdd($aPId, $aWin[$i][0])
	Next
	DLLClose($User32)
	For $i = UBound($aPId) -1 to 1 Step -1
		If $aPId[$i] == "" Then _ArrayDelete($aPId, $i)
	Next
	$aPId[0] = UBound($aPId) - 1
	Return $aPId
EndFunc
im array wird alles angezeigt, was ein Fenster ist und unter dem Prozess ist^^
Bin mir nicht sicher obs stimmt, muss ich mal auf lolkop warten
PenGuin :O is offline  
Old 11/19/2010, 16:16   #11
 
elite*gold: 0
Join Date: Sep 2010
Posts: 210
Received Thanks: 45
Geht es nun auch so das man Beides gleichzeitig rausfindet über den Process.
ja ich weiß das ist bissel doof ,
aber ich brauche das ja für einen Bot und dieser Bot soll auch mit mehrerer CLienten klar kommen deshalb soll er die Handle und Titel gleichzeitig rausfinden damit es da keine Probleme gibt.
Also normalerweise sind die titel die selben deswegen funktioniet auch nicht einfach WinGetHandle()
Lighthex is offline  
Old 11/19/2010, 18:21   #12
 
PenGuin :O's Avatar
 
elite*gold: 2
Join Date: Mar 2008
Posts: 1,778
Received Thanks: 1,222
Hast du mal mein Script getestet?
Wenn es funktioniert, hast du dich damit auch mal kurz befasst?

Weil es muss nur 1 Zahl geändert werden:

Code:
#include <Array.au3>

$ahWnd = _HwndByProcessName("iexplore.exe")
_ArrayDisplay($ahWnd)

Func _HwndByProcessName($sProcess)
	Local $iPId = 0, $aPId[1], $aResult
	$aProc = ProcessList()
	For $i = 1 To $aProc[0][0]
		If $aProc[$i][0] = $sProcess Then
			$iPId = $aProc[$i][1]
			ExitLoop
		EndIf
	Next
	$aWin = WinList()
	$User32 = DllOpen("user32.dll")
	For $i = 1 To $aWin[0][0]
		$aResult = DllCall($User32, "dword", "GetWindowThreadProcessId", "hwnd", $aWin[$i][1], "dword*", 0)
		If $aResult[2] = $iPId Then _ArrayAdd($aPId, $aWin[$i][[COLOR="Red"]1[/COLOR]])
	Next
	DLLClose($User32)
	For $i = UBound($aPId) -1 to 1 Step -1
		If $aPId[$i] == "" Then _ArrayDelete($aPId, $i)
	Next
	$aPId[0] = UBound($aPId) - 1
	Return $aPId
EndFunc
Einfach aus der 0 eine 1 machen, welchen Grund das hat, kannst ja mal selber checken.
PenGuin :O is offline  
Old 11/19/2010, 19:06   #13
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
das client handle muss auch im speicher des prozesses stehen.
kannst ja mal per window info tool das handle anzeigen lassen, und im speicher danach suchen...
so könntest du das einfach per memoryread auslesen, und müsstest nicht die liste aller fenster, nach dem zu deiner pid passenden durchsuchen...
lolkop is offline  
Old 11/19/2010, 21:11   #14
 
elite*gold: 0
Join Date: Sep 2010
Posts: 210
Received Thanks: 45
Das ist doche keine Addresse ...
Also irgendwie funktioniert die scheiße nicht also das mit dem Namen funktiniert ...
aber nicht mit dem Handle
Lighthex is offline  
Old 11/19/2010, 21:20   #15
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
wenn ein programm ein fester öffnet, muss das programm das auch wissen -.-

wenn das programm nicht das fensterhandle gespeichert hätte, könnte es weder das fenster nutzen, noch schließen.
daraus folgt, das das fenster handle IMMER im speicher stehen muss...
das handle aus dem speicher beziehen wäre in jedem fall die effizienteste lösung...

wenn du das allerdings nicht auf dem besten wege, sondern eher allgemein lösen willst, machs so wie es bereits gezeigt wurde mit winnlist...

hier mal wie man das ganze (wie in deinem falle warscheinlich nötig) mit nur einem fenster für den prozess lösen kann:
Code:
Func GetHandle($pid)
	Local $i, $list = WinList()
	For $i=1 To $list[0][0]
		If WinGetProcess($list[$i][1]) = $pid Then Return $list[$i][1]
	Next
EndFunc
lolkop is offline  
Reply


Similar Threads Similar Threads
Does anyone know how to handle this?
09/03/2010 - Mabinogi - 10 Replies
how to handle the mini game of metal conversion? Can you offer me a link or just post bellow?
Mit Process Explorer /Process Hacker Hs umgehen
05/22/2010 - General Gaming Discussion - 1 Replies
Ich habe hier im Forum gelesen, das man mit Process Explorer bzw. Process Hacker das HS umgehen kann. Leider ist mir irgendwie schleierhaft wie das gehen soll. Vllt erbarmt sich jemand und erklärt es (:, da man den sogenannten Bypasser nur noch las Premium Dings Da bei Upload.to runterladen kann :rolleyes:
[C++] Process Handle
10/27/2009 - C/C++ - 9 Replies
huhu, ich hab ein Problem den Process Handle von Diablo II zu bekommen. #include <cstdlib> #include <iostream> #include <windows.h> using namespace std;
C# how to pause a process/freeze process
12/08/2008 - CO2 Programming - 2 Replies
ya so i was semi bored and after little bit of looking around i didnt find to many examples of how to do this so attached is a demo project to show you how. basically it comes down to calling ResumeThread() and SuspendThread() (API functions) on all the threads of a process...simple enough http://img388.imageshack.us/img388/9762/exampleil 6.png please note when you enter the process name there's no ".exe" to the end Warning: this isn't idiot proof . .
get opened process handle to readwrite with a dll?
01/19/2008 - General Coding - 0 Replies
Hi, is there a way to inject a dll and get it's process handle for read/write..because the address i'm using is a point and to read the address first and then add the offset..



All times are GMT +2. The time now is 11:32.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.