Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
destroying a frozen aplication
#1
Hi

I need to know how to destroy an application. clo+ does not seem to work for me. I need a command that works like the windows task manager where you can destroy frozen programs

thanks, nate
#2
Function ShutdownProcess2:
Code:
Copy      Help
;/
function VARIANT'hwndOrExename [flags] ;;flags: 1 process id

;Terminates a process (running program).
;Preferred method to close program is clo or clo+, but if does not work (eg when hung), use this function.
;This function may leave invalid tab in taskbar.


;hwndOrExename - program name (without exe), or handle of some window that belongs to the process, or process id (then use flag 1).

;EXAMPLES
;ShutDownProcess2("NOTEPAD")
;ShutDownProcess2(win("" "Notepad"))



def PROCESS_TERMINATE    0x0001

int ph pid ghost
sel hwndOrExename.vt
,case VT_I4
,pid=hwndOrExename.lVal
,if(flags&1=0)
,,if(!pid) ret
,,if(wintest(pid "" "Ghost" "explorer")) end "It is a ghost window that belongs to EXPLORER process. To find correct window, use class name."
,,GetWindowThreadProcessId(pid &pid)
,case VT_BSTR
,_s=hwndOrExename
,pid=GetProcessId(_s)
,case else end ES_BADARG
if(!pid) ret

ph=OpenProcess(PROCESS_TERMINATE 0 pid)
if ph
,TerminateProcess(ph 0)
,CloseHandle(ph)
#3
This function is giving me an unknown identifier. I am using version 2.1.6. My other computer is on 2.1.4 but I have not tried it there. Is this only available on 2.1.8?
#4
pid=GetProcessId(_s)

this line of code, seventh line from buttom, the getprocessId is not in blue when I copy and paste it into my version of qm... why is that..
#5
Same here. That is the line that gave the error.
#6
Yes, it is only available in QM 2.1.8. You can create function GetProcessId and paste this code:

Code:
Copy      Help
;/
function# $exename

int pid fl hs k; str s se(exename); lpstr ss
if(se.endi(".exe")) fl|1

hs=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS 0); if(hs==-1) ret
PROCESSENTRY32 pe.dwSize=sizeof(PROCESSENTRY32)
k=Process32First(hs &pe)
rep
,if(!k) break
,ss=&pe.szExeFile
,s.getfilename(ss fl)
,if(s~se) pid=pe.th32ProcessID; break
,k=Process32Next(hs &pe)
,
CloseHandle(hs)
ret pid

Delete both these functions when you'll upgrade to 2.1.8 or later.
This is not tested on 2.1.6. May give more unknown identifier errors.
#7
Yes, I just tried it on 2.1.6 and got "CreateToolhelp32Snapshot" error in GetProcessId.
#8
It is only available in QM 2.1.8 so you'll have to update.
An old blog on QM coding and automation.

The Macro Hook
#9
In Qm 2.1.6, these functions etc should be declared somewhere. Find(toolbar -> Find) them, copy and paste in the next line after function# $exename.
#10
:oops: I just lost you there lmao!

Anyhow, I found this on previous post and modified it. Won't this work?

Code:
Copy      Help
int process_handle
process_handle=("notepad.exe")
..
clo "notepad"
TerminateProcess process_handle 1
CloseHandle process_handle

To use TerminateProcess, must be the execution file?



or how about this one. also found this on previous post:

Code:
Copy      Help
run "notepad.exe"
60
clo "Notepad"
ShutDownProcess win("- Notepad")
#11
im trying to get the first code to work but now im getting a bad agument error on this line

case else end ES_BADARG
#12
Wouldn't it be better if there was a separate function to check if the application is actually frozen before you try to shut it down? I am not sure if this is even possible but Guru Gintaras here have been a very good magician :lol:
#13
Quote:check if the application is actually frozen before you try to shut it down

Search forum for IsHungAppWindow.

Quote:case else end ES_BADARG

Delete this line.
#14
not what im looking for. I just want a very simple function that will destroy the application just like "windows task manager"...... If its frozen or not.. clo or clo+ will not close it if its frozen so that wont work..' sorry, I just cant get the ones working that you posted..Is there something simpler?

thanks, nate
#15
sorry guys still cant make it work.. I take notpad as an example. you know when you close notepad and this child window pops up asking if you want to save your work.

I need a function that will destroy the program if the child window pops up or not. So no matter what It should destroy the program or teminate the whole proccess


thanks for your help anyone.
#16
Code:
Copy      Help
ShutDownProcess win("" "Notepad")


Forum Jump:


Users browsing this thread: 2 Guest(s)