Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Process suspend and unsuspend


  • Please log in to reply
10 replies to this topic
Guest11111111112
  • Guests
  • Last active:
  • Joined: --
Hi,

I am trying to find someone that can create a script to suspend a process after a certain amount of time it has been open for and then once it gets suspended, a msg box opens with an ok button

Once the ok button has been pushed, the process will then resume.

Can anyone help me out please.

P.S i have used the search function on this forum and have found nothing as to what i am asking for.

Cheers.

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
It's impossible to do that with a little script.

Some explanations here :

<!-- m -->http://www.codeproje... ... esume-tool<!-- m -->

spazman6117
  • Members
  • 5 posts
  • Last active: May 23 2013 09:25 AM
  • Joined: 02 Apr 2012

It's impossible to do that with a little script.

Some explanations here :

<!-- m -->http://www.codeproje... ... esume-tool<!-- m -->


Tried that and couldnt get it to work.

berban did create a script that was about 30 lines long but i accidentally deleted it and my firefox doesnt remember web addresses i visit and forgot to save the address to the script he made me.....

But im sure there is more than 1 person capable of writing such a script.

i know it started with

Proc1 = xxd.xem


EDIT: NVM, i typed Proc1 = xxd.xem into google and it was the first link :)

http://pastebin.com/SNsRSxv5

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
Can't access to pastebin, can tou poste it here ? I'm interested. ;-)

spazman6117
  • Members
  • 5 posts
  • Last active: May 23 2013 09:25 AM
  • Joined: 02 Apr 2012
Sure thing,

Proc1 = Process1 (Change this to the 1st process u want to suspend/pause)

Proc2 = Process2 (Change this to the 2nd process u want to suspend/pause)

;----------------------------------------------------------------------------------------------------

Process, Priority, , High
SetBatchLines, -1
Params = %1%
If Params {
	Process, Wait, %Proc2%
	ProcSus(Proc2)
} Else {
	Run, "%A_AhkPath%" "%A_ScriptFullPath%" berban
	Process, Wait, %Proc1%
	ProcSus(Proc1)
	Process, Wait, %Proc2%
	MsgBox, 262144, %A_ScriptName%: Alert, Processes have been suspended!`n`nPress OK when you are done cheating :)
	ProcRes(Proc1), ProcRes(Proc2)
}

ExitApp

;=============================================[Std.ahk]=============================================

ProcSus(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

ProcRes(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

If you want me to change it for you so it only suspends 1 process instead of 2 let me know. I edited to only suspend the 1st process it detects.

The script he wrote was kinda not balance because the script only pauses the 1st process IF the 2nd process is present as well and seeing how my Process 2 opened AFTER process 1 loaded....it was flawed

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
So Microsoft finaly added these features directly into ntdll.dll.
Good to know. :D

spazman6117
  • Members
  • 5 posts
  • Last active: May 23 2013 09:25 AM
  • Joined: 02 Apr 2012
i edited my post too late....please acknowledge my edit to make sure you saw it

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
Full script to "manage" process :

Processes := Object()
Gui Add, ListView, -Multi, PID|Windows Name
Gui Add, Button, gRes, Resume selected process
Gui Show

Return

Res:
	Next := LV_GetNext(0, "Focused")
	LV_GetText(PID, 1)
	LV_GetText(ProcessName, 2)
	If (ProcRes(PID) <> -1) {
		LV_Delete(Next)
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% resumed.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while resuming process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F1::
    WinGet ProcessName, ProcessName, A
    WinGet PID, PID, A
	SetFormat Integer, H
	PID +=0
	SetFormat Integer, D
	If (ProcSus(PID) <> -1) {
		LV_Add("", PID, ProcessName)
		LV_ModifyCol()
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% suspended.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while suspending process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F2::
	If (Last And PID And ProcessName) {
		If (ProcRes(PID) <> -1) {
			LV_Delete(Last)
			Last := LV_GetCount()
			ToolTip Process %PID% %ProcessName% resumed.
			SetTimer TP, 1500
		} Else {
				ToolTip Error while resuming the last process !
				SetTimer TP, 1500
			}
	} Else {
		ToolTip No process to resume.
		SetTimer TP, 1500
	}
Return

TP:
	ToolTip
Return

ProcSus(PID_or_Name) 
{ 
   If InStr(PID_or_Name, ".") { 
      Process, Exist, %PID_or_Name% 
      PID_or_Name := ErrorLevel 
   } 
   If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name)) 
      Return -1 
   DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h) 
} 

ProcRes(PID_or_Name) 
{ 
   If InStr(PID_or_Name, ".") { 
      Process, Exist, %PID_or_Name% 
      PID_or_Name := ErrorLevel 
   } 
   If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name)) 
      Return -1 
   DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h) 
}

:wink:

spazman6117
  • Members
  • 5 posts
  • Last active: May 23 2013 09:25 AM
  • Joined: 02 Apr 2012
Question,

What does that do exactly?

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
Just a gui to manage the currently suspended process so you can suspend as many process as you want and resume them in the order you want.

Better version :
Title := "AHK Process Management Script"
Gui Add, ListView, -Multi, PID|Windows Name
Gui Add, Button, gRes, Resume selected process
Gui Show, , %Title%
SetFormat Integer, H
WinGet AHK_PID, PID, %Title%
SetFormat Integer, D
Return

Res:
	Next := LV_GetNext(0, "Focused")
	LV_GetText(PID, 1)
	LV_GetText(ProcessName, 2)
	If (ProcRes(PID) <> -1) {
		LV_Delete(Next)
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% resumed.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while resuming process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F1::
	WinGet ProcessName, ProcessName, A
	SetFormat Integer, H
	WinGet PID, PID, A
	SetFormat Integer, D
	If (PID = AHK_PID) {
		ToolTip Process %PID% %ProcessName% can't be suspended : script process !
		SetTimer TP, 2500
		Return
	}
	If (ProcSus(PID) <> -1) {
		LV_Add("", PID, ProcessName)
		LV_ModifyCol()
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% suspended.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while suspending process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F2::
	If (Last And PID And ProcessName) {
		If (ProcRes(PID) <> -1) {
			LV_Delete(Last)
			Last := LV_GetCount()
			ToolTip Process %PID% %ProcessName% resumed.
			SetTimer TP, 1500
		} Else {
				ToolTip Error while resuming the last process !
				SetTimer TP, 1500
			}
	} Else {
		ToolTip No process to resume.
		SetTimer TP, 1500
	}
Return

TP:
	ToolTip
Return

ProcSus(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

ProcRes(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

Doesn't allow user to Suspend script's process. ;)

Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Full script to "manage" process :
 

Processes := Object()
Gui Add, ListView, -Multi, PID|Windows Name
Gui Add, Button, gRes, Resume selected process
Gui Show

Return

Res:
	Next := LV_GetNext(0, "Focused")
	LV_GetText(PID, 1)
	LV_GetText(ProcessName, 2)
	If (ProcRes(PID) <> -1) {
		LV_Delete(Next)
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% resumed.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while resuming process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F1::
    WinGet ProcessName, ProcessName, A
    WinGet PID, PID, A
	SetFormat Integer, H
	PID +=0
	SetFormat Integer, D
	If (ProcSus(PID) <> -1) {
		LV_Add("", PID, ProcessName)
		LV_ModifyCol()
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% suspended.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while suspending process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F2::
	If (Last And PID And ProcessName) {
		If (ProcRes(PID) <> -1) {
			LV_Delete(Last)
			Last := LV_GetCount()
			ToolTip Process %PID% %ProcessName% resumed.
			SetTimer TP, 1500
		} Else {
				ToolTip Error while resuming the last process !
				SetTimer TP, 1500
			}
	} Else {
		ToolTip No process to resume.
		SetTimer TP, 1500
	}
Return

TP:
	ToolTip
Return

ProcSus(PID_or_Name) 
{ 
   If InStr(PID_or_Name, ".") { 
      Process, Exist, %PID_or_Name% 
      PID_or_Name := ErrorLevel 
   } 
   If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name)) 
      Return -1 
   DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h) 
} 

ProcRes(PID_or_Name) 
{ 
   If InStr(PID_or_Name, ".") { 
      Process, Exist, %PID_or_Name% 
      PID_or_Name := ErrorLevel 
   } 
   If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name)) 
      Return -1 
   DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h) 
}

:wink:

 

Just a gui to manage the currently suspended process so you can suspend as many process as you want and resume them in the order you want.

Better version :

Title := "AHK Process Management Script"
Gui Add, ListView, -Multi, PID|Windows Name
Gui Add, Button, gRes, Resume selected process
Gui Show, , %Title%
SetFormat Integer, H
WinGet AHK_PID, PID, %Title%
SetFormat Integer, D
Return

Res:
	Next := LV_GetNext(0, "Focused")
	LV_GetText(PID, 1)
	LV_GetText(ProcessName, 2)
	If (ProcRes(PID) <> -1) {
		LV_Delete(Next)
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% resumed.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while resuming process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F1::
	WinGet ProcessName, ProcessName, A
	SetFormat Integer, H
	WinGet PID, PID, A
	SetFormat Integer, D
	If (PID = AHK_PID) {
		ToolTip Process %PID% %ProcessName% can't be suspended : script process !
		SetTimer TP, 2500
		Return
	}
	If (ProcSus(PID) <> -1) {
		LV_Add("", PID, ProcessName)
		LV_ModifyCol()
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% suspended.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while suspending process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F2::
	If (Last And PID And ProcessName) {
		If (ProcRes(PID) <> -1) {
			LV_Delete(Last)
			Last := LV_GetCount()
			ToolTip Process %PID% %ProcessName% resumed.
			SetTimer TP, 1500
		} Else {
				ToolTip Error while resuming the last process !
				SetTimer TP, 1500
			}
	} Else {
		ToolTip No process to resume.
		SetTimer TP, 1500
	}
Return

TP:
	ToolTip
Return

ProcSus(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

ProcRes(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

Doesn't allow user to Suspend script's process. wink.png

 

Just a gui to manage the currently suspended process so you can suspend as many process as you want and resume them in the order you want.

Better version :

Title := "AHK Process Management Script"
Gui Add, ListView, -Multi, PID|Windows Name
Gui Add, Button, gRes, Resume selected process
Gui Show, , %Title%
SetFormat Integer, H
WinGet AHK_PID, PID, %Title%
SetFormat Integer, D
Return

Res:
	Next := LV_GetNext(0, "Focused")
	LV_GetText(PID, 1)
	LV_GetText(ProcessName, 2)
	If (ProcRes(PID) <> -1) {
		LV_Delete(Next)
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% resumed.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while resuming process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F1::
	WinGet ProcessName, ProcessName, A
	SetFormat Integer, H
	WinGet PID, PID, A
	SetFormat Integer, D
	If (PID = AHK_PID) {
		ToolTip Process %PID% %ProcessName% can't be suspended : script process !
		SetTimer TP, 2500
		Return
	}
	If (ProcSus(PID) <> -1) {
		LV_Add("", PID, ProcessName)
		LV_ModifyCol()
		Last := LV_GetCount()
		ToolTip Process %PID% %ProcessName% suspended.
		SetTimer TP, 1500
	} Else {
		ToolTip Error while suspending process : %PID% %ProcessName% !
		SetTimer TP, 1500
	}
Return

^F2::
	If (Last And PID And ProcessName) {
		If (ProcRes(PID) <> -1) {
			LV_Delete(Last)
			Last := LV_GetCount()
			ToolTip Process %PID% %ProcessName% resumed.
			SetTimer TP, 1500
		} Else {
				ToolTip Error while resuming the last process !
				SetTimer TP, 1500
			}
	} Else {
		ToolTip No process to resume.
		SetTimer TP, 1500
	}
Return

TP:
	ToolTip
Return

ProcSus(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtSuspendProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

ProcRes(PID_or_Name)
{
	If InStr(PID_or_Name, ".") {
		Process, Exist, %PID_or_Name%
		PID_or_Name := ErrorLevel
	}
	If !(h := DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", PID_or_Name))
		Return -1
	DllCall("ntdll.dll\NtResumeProcess", "Int", h), DllCall("CloseHandle", "Int", h)
}

Doesn't allow user to Suspend script's process. wink.png

 

 This so-called "AHK Process Management Script" killed my machine (had to restart). angry.png