Jump to content

Freeze system/specified program


Recommended Posts

I would like a program to freeze when I hit a certain hotkey and then listen at another hotkey to "respond" the program/process. I know how to do this and I thought of a while loop when hotkey got hitted, however my main problem is: I don't find a function for it. Could someone help me to find it in MSDN (& optional make it autoit muttley)?

THANKS!

Link to comment
Share on other sites

Search "pause".

Thank you, I did this but the only things I found was functions for pausing the own application and some topics on timers. Did you understand what I ment, should I clarify; I want to be able to for example freeze notepad.exe so it is not usable until a hotkey it hit. Thanks in advance!
Link to comment
Share on other sites

Thank you, I did this but the only things I found was functions for pausing the own application and some topics on timers. Did you understand what I ment, should I clarify; I want to be able to for example freeze notepad.exe so it is not usable until a hotkey it hit. Thanks in advance!

WinSetState()?
Link to comment
Share on other sites

Maybe this might help you.

Dim $Pause = 0
HotKeySet("{F2}", "Paus")
Func Paus()
    ToolTip('Paused', 470, 200)
    Sleep(500)
    $Pause = $Pause + 1
    PauseCheck()
EndFunc ;==>Paus
Func PauseCheck()
    If $Pause = 1 Then
    Sleep(1980 + Random(20, 60, 1))
    PauseCheck()
Elseif
ToolTip('', 470, 200);kills paused tooltip
EndIf
Edited by JamesDover
Link to comment
Share on other sites

Maybe this might help you.

Dim $Pause = 0
HotKeySet("{F2}", "Paus")
Func Paus()
    ToolTip('Paused', 470, 200)
    Sleep(500)
    $Pause = $Pause + 1
    PauseCheck()
EndFunc;==>Paus
Func PauseCheck()
    If $Pause = 1 Then
    Sleep(1980 + Random(20, 60, 1))
    PauseCheck()
Elseif
ToolTip('', 470, 200);kills paused tooltip
EndIf
Thanks, but this just pauses the program itself, I want the program able to pause another program. Rendering the program unable to do anything...

WinSetState()?

Ye that fixes so the user isn't able to use the window, but what if the process will keep on for example downloading something? Edited by LinuZ
Link to comment
Share on other sites

Hiho, I searched for the problem and I found a source code in autohotkey any guru knows how to make it work?

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
}

^the autohotkey code^

My try, correct me please muttley

#Include <WinAPI.au3>

$process = _WinAPI_OpenProcess("PROCESS_SUSPEND_RESUME", 1, "process.exe")

DllCall("ntdll.dll", "Int", "NtSuspendProcess", "Int", $process)

DllCall("Kernel32.dll", "Int", "CloseHandle", "Int", $process)

EDIT: Ahh, never mind... I found CoProc! Thanks for those you helped :)

Edited by LinuZ
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...