How terminate a Process under the mouse (+2 gags)

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

Not to close a window under the Mouse (that is easy). I want to close a application, even when the application can't recieve a message (when it hangs, don't answer).

My code

Code: Select all

       maus.point 
       getcursorpos_(maus) 
       handle=windowfrompoint_(maus\x,maus\y) 
       processid=0 
       thread= GetWindowThreadProcessId_(handle,@processid) 
       terminateprocess_(processid,0)
but it don't work. I have checked the errorcode and it saied, that the processid is invalid.

p.s.:
Try this

Code: Select all

  postmessage_(findwindow_("Shell_TrayWnd",0),#wm_quit,0,0)
and your task-bar is gone...

p.p.s.:

Code: Select all

  handle=findwindow_("Shell_TrayWnd",0) 
  If handle 
   handle=getwindow_(handle,#GW_CHILD) 
   If handle 
    class$=Space(1024): 
    getclassname_(handle,@class$,Len(class$)) 
    If Left(class$,Len(class$))="Button" 
     postmessage_(handle,#wm_close,0,0) 
    EndIf 
   EndIf 
  EndIf
And your Start-Button is gone...

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Maybe you have to do "attach" like...

Code: Select all

Procedure ForceWindowToFront(hWT)
  ShowWindow_(hWT, #SW_HIDE)
  
  hWC = GetForeGroundWindow_()

  If hWT  hWC
    threadID1 = GetWindowThreadProcessID_(hWT, 0)
    threadID2 = GetWindowThreadProcessID_(hWC, 0)

    If ( threadID1  threadID2 )
      AttachThreadInput_( threadID1, threadID2, #TRUE)
      SetForeGroundWindow_(hWT)
      AttachThreadInput_( threadID1, threadID2, #FALSE)
    Else
      SetForeGroundWindow_(hWT);
    EndIf
  EndIf

  ShowWindow_(hWT, #SW_SHOW);
EndProcedure
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

I found a method

Code: Select all

#PROCESS_ALL_ACCESS=$FFF
maus.point
getcursorpos_(maus)
handle=windowfrompoint_(maus\x,maus\y)

processid=0
thread=getwindowthreadprocessid_(handle,@processid)
process=OpenProcess_(#PROCESS_ALL_ACCESS,1,processid)
terminateprocess_(process,0)
closehandle_(process)
Work on Win98SE (maybe not under win2000/XP)

BIG WARNING: IT IS POSSIBLE TO CLOSE THE TASKBAR.

Bevor running the programm, place the mouse-cursor over a Window, which should be closed. Also remember, the programm will kill instant, so it has no possibility to save sourcecode or like this.

Funny Fact: When you close the purebasic-help, also purebasic will be closed.

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
Post Reply