Results 1 to 8 of 8

Thread: Working with Processes in Girder 6

  1. #1
    Join Date
    Jun 2012
    Location
    Wabash, IN
    Posts
    99

    Default Working with Processes in Girder 6

    Does anyone happen to know how I can find and kill a process in Girder 6?

    In Girder 5, I wrote a lua script as follows...

    Code:
    -- get the process if it exists
    procId = win.FindProcess("spotify.exe")
    
    -- if the process exists, terminate it
    if procId ~= nil then
    	res = win.TerminateProcess(procId)
    	print("The spotify process was terminated.")
    else
    	print("The spotify process wasn't found.")
    end
    I searched through the manual and on the forums and didn't find anything pertaining to Girder 6.

    Thanks,
    Casey

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    That's a pretty hard terminate there. Is there a reason you are using TerminateProcess over closeWindow?

    I'd use win.findWindowEx(...) (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx) and win.closeWindow(...)

    Code:
    local wnd = win.findWindowEx(0,0, "", "spotify.exe")  -- you might have to get the classname too.
    
    if wnd then
    
      win.closeWindow(wnd)
      print ("Found and close sent", wnd)
    else 
      print("Could not find")
    end
    Ron
    No support through PM

  3. #3
    Join Date
    Jun 2012
    Location
    Wabash, IN
    Posts
    99

    Default

    Hi Ron,

    Unfortunately Spotify seems to leave a lot of processes running in the background and just closing it's window isn't enough. I was using the code above in Girder 5 and it was working beautifully. I agree it's a harsh way to terminate an application but the application just doesn't seem to want to close completely any other way I've found. So is there any way in 6 to Find and Terminate a process?

    Thanks,
    Casey

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    I understand. I'll add those functions back in. Hopefully I'll get a bit of time for that tomorrow.
    Ron
    No support through PM

  5. #5
    Join Date
    Jun 2012
    Location
    Wabash, IN
    Posts
    99

    Default

    Hi Ron,
    In the short term I found a way to kill a process using ShellExecute...

    Filename: C:\Windows\System32\taskkill.exe
    Working Directory: C:\Windows\System32
    Parameters: /F /IM Spotify.exe
    Session:
    Flags: SHOWNORMAL
    Verb: open

    I'm also killing off the SpotifyWebHelper.exe process in the same fashion. Hopefully this helps someone else in the future.

    Thanks,
    Casey

  6. #6
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Next release has these functions built in again.
    Ron
    No support through PM

  7. #7
    Join Date
    Jun 2012
    Location
    Wabash, IN
    Posts
    99

    Default

    Do you ever sleep Ron? Seems you're always on here or working on Girder and releasing changes very quickly. I applaud your dedication!

  8. #8
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Thank you for your kind words!
    Ron
    No support through PM

Tags for this Thread

Posting Permissions

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