Jump to content

Suspend a process


Alterego
 Share

Recommended Posts

I developed this because I am working with a program that does not have traditional GUI controls, meaning it definitely did not respect @SW_HIDE, and I wanted to completely move it off the screen before it had a chance to think. I was successful except for the brief flash of the splash screen. With this snippet of code and some trial and error timing, I was able to freeze the splash screen and get the title.

As you will see with this code, notepad is frozen so quickly that it doesn't have a chance to draw the GUI.

You will need to download process explorer from sysinternals and drop procexp.exe in your @WindowsDir.

;$letter equals the first letter of the process name.
;If the process will be the second, third etc... starting
;with that letter, enter the key n times to arrive at the
;correct process, e.g, _suspend('notepad.exe','nnn)

$process = 'notepad.exe'
$letter = 'n'

Run($process,'',@SW_HIDE)

_suspend($process,$letter)

Func _suspend($process,$letter)

    Run("procexp.exe",'',@SW_HIDE)
    WinActivate("Process")
    ControlSend("Process",'',101,$letter & "!p{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
    ProcessClose("procexp.exe")

EndFunc

Edit: Just call _suspend() again to resume the process!

suspend.au3

Edited by Alterego
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...