Code: Alles auswählen
;Hier hol ich die ID her.....
Procedure ProcessID(Name.s)
;Nach aktivem Process suchen
Protected result.l, Snapshot.l, ProcessFound.l, PN$, Process.PROCESSENTRY32
result = #False
Process\dwSize = SizeOf(PROCESSENTRY32)
Snapshot = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
If Snapshot
ProcessFound = Process32First_(Snapshot, Process)
While ProcessFound
PN$ = UCase(PeekS(@Process\szExeFile, #PB_Any, #PB_Ascii))
If UCase(Name) = GetFilePart(PN$) : result = #True : Break : EndIf
ProcessFound = Process32Next_(Snapshot, Process)
Wend
CloseHandle_(Snapshot)
EndIf
If Result = #True
ProcedureReturn Process\th32ProcessID
EndIf
EndProcedure
;Hier noch ne geklaute Procedure fürs Handle die eigentlich gehn sollte ??...
Procedure.l ProcID2hWnd(ProcID.l)
Protected hwnd.l
Protected ProcTaskID.l
hwnd = FindWindow_(#Null, #Null)
While hwnd <> 0
GetWindowThreadProcessId_(hwnd, @ProcTaskID)
If ProcTaskID = ProcID
ProcedureReturn hwnd
EndIf
hwnd.l = GetWindow_(hwnd, #GW_HWNDNEXT)
Wend
EndProcedure
;Vielleicht liegt es am Programm ?? mit Notepad geht es ??
id.l = processid("ZSNESW.EXE") ;Der Supernintendo Emulator ZSNESW.EXE soll im Vordergrund bleiben
hwnd.l = procid2hwnd(id.l)
;wenn man diese Api und das zu startende Programm extern(also über Windows) schliesst und nochmal ausführt.....geht es ?????
SetWindowPos_(hwnd, #HWND_TOPMOST, 0, 0, 100, 100, #SWP_NOACTIVATE | #SWP_SHOWWINDOW | #SWP_NOMOVE | #SWP_NOSIZE)Code-Tags hinzugefügt
06.11.2013
RSBasic