Results 1 to 6 of 6

Thread: Kill a window if window title contains...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    113

    Talking Kill a window if window title contains...

    Photoshop for example.

    I'd like my app to kill any window that has the word "photo" in the window title. Tried goggling but it's hard because I don't know exactly how to describe it.

    Thanks!

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Kill a window if window title contains...

    You do the same thing you did over here, except to terminate s process replace p.CloseMainWindow() with p.Kill() , and of course change the string to "photo" or whatever.
    Last edited by Edgemeal; Jul 17th, 2014 at 11:33 PM. Reason: add string to "photo"

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Kill a window if window title contains...

    A also use regex so you dont have to take it.

    vb Code:
    1. Imports System.Text.RegularExpressions
    2.  
    3. Public Class Form1
    4.  
    5.     Private Sub Foo()
    6.         Dim procs = Process.GetProcesses.Where(Function(p) WindowIsMatch(p.MainWindowTitle))
    7.         Array.ForEach(procs.ToArray, Sub(p) p.Kill())
    8.     End Sub
    9.  
    10.     Private Function WindowIsMatch(process As String) As Boolean
    11.         Return New Regex("(?i)photo").IsMatch(process)
    12.     End Function
    13.  
    14. End Class

  4. #4
    Member
    Join Date
    Oct 2013
    Posts
    41

    Re: Kill a window if window title contains...

    this sounds a bit dubious to me, to be honest. I know there are a bunch of malware programs that do exactly this.

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Kill a window if window title contains...

    I do not think that it is against the site regulations to show how to kill a process.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Kill a window if window title contains...

    Quote Originally Posted by Jet Black View Post
    this sounds a bit dubious to me, to be honest. I know there are a bunch of malware programs that do exactly this.
    I doubt this member is a threat to Dade "Zero Cool" Murphy crashing 1,507 computer systems in a single day and causing a single-day 7-point drop in the New York Stock Exchange. Sorry wanted to quote that for old sakes.

    On a serious note no REAL Malware bothers with kiddy killing processes by window title. Take VAULT for example. Ha i just remembered i had a dream last night and exicuted the i-love-you virus on my machine for fun. How strange.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width