#include #include Func _ProcessSuspendResume($iPIDorName, $iSuspend = True) If IsString($iPIDorName) Then $iPIDorName = ProcessExists($iPIDorName) If Not $iPIDorName Then Return SetError(2, 0, 0) ; Consider using $PROCESS_SUSPEND_RESUME = 0x00000800 instead of $PROCESS_ALL_ACCESS Local $ai_Handle = _WinAPI_OpenProcess( $PROCESS_ALL_ACCESS, False, $iPIDorName ) ;Local $ai_Handle = DllCall("kernel32.dll", 'int','OpenProcess', 'int', 0x1f0fff, 'int',False, 'int',$iPIDorName)[0] ; Note: "NtSuspendProcess" is an undocumented API Local $i_sucess = DllCall("ntdll.dll","int","Nt" & ($iSuspend ? "Suspend" : "Resume") & "Process" _ ,"int",$ai_Handle) _WinAPI_CloseHandle($ai_Handle) ;DllCall('kernel32.dll', 'ptr','CloseHandle', 'ptr',$ai_Handle) If IsArray($i_sucess) Then Return 1 Return SetError(1, 0, 0) EndFunc ;==>_ProcessSuspendResume <-based on: http://autoitscript.com/forum/topic/32975-process-suspendprocess-resume-udf/ Func TogglePause() $g_bPaused = Not $g_bPaused ;~ $PIDorName = $TARGET_PROCESSNAME $PIDorName = WinGetProcess("[ACTIVE]") _ProcessSuspendResume($PIDorName, $g_bPaused) EndFunc ;==>TogglePause ; The more 'offical' & easy way (http://stackoverflow.com/a/11010508/3135511) Func _ProcessSuspendResume2($iPIDorName, $iSuspend = True) If IsString($iPIDorName) Then $iPIDorName = ProcessExists($iPIDorName) If Not $iPIDorName Then Return SetError(2, 0, 0) if $iSuspend then ;Note Opens Process with PROCESS_ALL_ACCESS DllCall('kernel32.dll','ptr','DebugActiveProcess','int',$iPIDorName) ; you may leave out DebugSetProcessKillOnExit; however then your supended App will also Exit when you quit this AutoIt App DllCall('kernel32.dll','ptr','DebugSetProcessKillOnExit','int',False) Else DllCall('kernel32.dll','ptr','DebugActiveProcessStop','int',$iPIDorName) EndIf EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Global Const $APP_NAME = "Pause for Windows" Global Const $TARGET_PROCESSNAME = "JewelQuestSapphireDragon.exe" ; Base on the 'HotKeySet' sample from the AutoIt help ; Press Esc to terminate script, Pause/Break to "pause" Global $g_bPaused = False HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!h", "ShowMessage") ; Shift-Alt-h While 1 Sleep(100) WEnd Func Terminate() Exit EndFunc ;==>Terminate Func ShowMessage() MsgBox($MB_SYSTEMMODAL, APP_NAME & " - Help", "Press the >Pause< Key to your keyboard to suspend the current Process" & @CRLF & _ "(= the one whose windows is active)." & @CRLF & _ "Press >Pause< again to resume it.") EndFunc ;==>ShowMessage