Sign in to follow this  
Followers 0
au3scr

ProcessPause()

6 posts in this topic

ProcessPause(<"Process Name or PID">, <flag>)

Freeze a process.

<flag> is 0 to freeze the first occurrence, 1 to freeze all occurrences.

I have seen this but i cant use this command

can some one say where i can find script that does this command?


Share this post


Link to post
Share on other sites



Hi! Try this:

_ProcessPauseSwitch("ProcName.exe", True) 
Sleep(3000) 
_ProcessPauseSwitch("ProcName.exe", False) 
 
Func _ProcessPauseSwitch($iPIDOrName, $iSuspend = True) 
    If IsString($iPIDOrName) Then $iPIDOrName = ProcessExists($iPIDOrName) 
    If Not $iPIDOrName Then Return SetError(1, 0, 0) 
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPIDOrName) 
    If $iSuspend Then 
        Local $i_sucess = DllCall("ntdll.dll", "int", "NtSuspendProcess", "int", $ai_Handle[0]) 
    Else 
        Local $i_sucess = DllCall("ntdll.dll", "int", "NtResumeProcess", "int", $ai_Handle[0]) 
    EndIf 
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle) 
    If IsArray($i_sucess) Then Return 1 
    Return SetError(2, 0, 0) 
EndFunc

:)

Share this post


Link to post
Share on other sites

Well I will give this a try. In the example you gave, what does this part do:

Func _ProcessPauseSwitch($iPIDOrName, $iSuspend = True)

It seems like it accepts a 2nd parameter, and then sets it to 'TRUE'. Please explain.


What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.

Share this post


Link to post
Share on other sites

Well I will give this a try. In the example you gave, what does this part do:

Func _ProcessPauseSwitch($iPIDOrName, $iSuspend = True)

It seems like it accepts a 2nd parameter, and then sets it to 'TRUE'. Please explain.

Second parameter is to suspend(true) or resume(false).

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Second parameter is to suspend(true) or resume(false).

I understand that what the parameter is being used for in the function. I don't however understand why its being set to 'TRUE' right @ the start. In my mind, that function will never hit the ELSE stmt because its always being set to true right in the start of the function. Now I'm guessing thats not whats going on, and I'm looking for an explanation of what that first part does:

Func _ProcessPauseSwitch($iPIDOrName, $iSuspend = True)


What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.

Share this post


Link to post
Share on other sites

It's the default, if you don't supply a second parameter.

See:

Keyword Reference

Func...Return...EndFunc

in the help file

OOOH That makes sense. That is pretty cool! I'll have to start using that in my code b/c I have had a lot of places I didn't always want to include a parameter, and I kept getting the ol "Incorrect Number of Subscripts".


What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.

Share this post


Link to post
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
Sign in to follow this  
Followers 0