Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Process, Suspend/Resume, example.exe


  • Please log in to reply
3 replies to this topic

Poll: Should it be added to AHK? (10 member(s) have cast votes)

Should it be added to AHK?

  1. Yesh (4 votes [33.33%])

    Percentage of vote: 33.33%

  2. Nesh (6 votes [50.00%])

    Percentage of vote: 50.00%

  3. I can lick my toe (2 votes [16.67%])

    Percentage of vote: 16.67%

Vote Guests cannot vote
Ice_Tea
  • Members
  • 131 posts
  • Last active: Aug 25 2010 11:11 AM
  • Joined: 12 Jan 2008
Hey, there is a command i tend to use to freeze processes, and later resuming them... and to do this with AHK I have to use a another CMDtool to do it, so i were wondering if you could possible add these commands:

; Suspend the process
Process, Suspend, example.exe

; Resume Suspended process
Process, Resume, example.exe

This could be useful if you need more CPU cycles, you could temporary freeze the processes thread to temporarily give other stuff more time and then simply resume the frozen process, this way you don't have to close the program.

(I did try doing a search through the forum, but as I've said before, the search function in all forums is useless... tried googling through the forum too...)

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

tried googling through the forum too...

I used site:autohotkey.com suspend process and got Suspend Process as the first result.
Just for kicks, I also tried the site's own search function and again got Suspend Process as the first result.

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008

Run, Notepad.exe

WinWait, ahk_class Notepad

Process_Suspend("Notepad.exe")

MsgBox, Notepad.exe suspended

Sleep, 5000

Process_Resume("Notepad.exe")

MsgBox, Notepad.exe resumed

Exitapp



;============================== Working on WinXP+

Process_Suspend(PID_or_Name){

    PID := (InStr(PID_or_Name,".")) ? ProcExist(PID_or_Name) : PID_or_Name

    h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)

    If !h   

        Return -1

    DllCall("ntdll.dll\NtSuspendProcess", "Int", h)

    DllCall("CloseHandle", "Int", h)

}



Process_Resume(PID_or_Name){

    PID := (InStr(PID_or_Name,".")) ? ProcExist(PID_or_Name) : PID_or_Name

    h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)

    If !h   

        Return -1

    DllCall("ntdll.dll\NtResumeProcess", "Int", h)

    DllCall("CloseHandle", "Int", h)

}



ProcExist(PID_or_Name=""){

    Process, Exist, % (PID_or_Name="") ? DllCall("GetCurrentProcessID") : PID_or_Name

    Return Errorlevel

}

Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com

Ice_Tea
  • Members
  • 131 posts
  • Last active: Aug 25 2010 11:11 AM
  • Joined: 12 Jan 2008

Run, Notepad.exe
WinWait, ahk_class Notepad
Process_Suspend("Notepad.exe")
MsgBox, Notepad.exe suspended
Sleep, 5000
Process_Resume("Notepad.exe")
MsgBox, Notepad.exe resumed
Exitapp

;============================== Working on WinXP+
Process_Suspend(PID_or_Name){
    PID := (InStr(PID_or_Name,".")) ? ProcExist(PID_or_Name) : PID_or_Name
    h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)
    If !h   
        Return -1
    DllCall("ntdll.dll\NtSuspendProcess", "Int", h)
    DllCall("CloseHandle", "Int", h)
}

Process_Resume(PID_or_Name){
    PID := (InStr(PID_or_Name,".")) ? ProcExist(PID_or_Name) : PID_or_Name
    h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)
    If !h   
        Return -1
    DllCall("ntdll.dll\NtResumeProcess", "Int", h)
    DllCall("CloseHandle", "Int", h)
}

ProcExist(PID_or_Name=""){
    Process, Exist, % (PID_or_Name="") ? DllCall("GetCurrentProcessID") : PID_or_Name
    Return Errorlevel
}


oh snap will you marry me?