Sign in to follow this  
Followers 0
gil900

CrapIT - run your program with crap preformance (defined speed)

4 posts in this topic

#1 ·  Posted (edited)

This script allow you to run any process in slow speed mode.

It use

To make it posibole.

 

Script:

Global $ExePath, $iSleep, $iExePid

$ExePath = FileOpenDialog('Select the exe file to run in slow motion mode','','Exe files (*.exe)')
If @error Then Exit

$iSleep = InputBox('Set Sleep value','Select the Sleep value',100)



$iExePid = Run($ExePath)
If @error Then Exit ConsoleWrite('Error' & ' (L: ' & @ScriptLineNumber & ')' & @CRLF)

OnAutoItExitRegister(OnExitEvent)


Global $iTimer, $bSuspended = False, $iTimer2

While Sleep(1)
    If TimerDiff($iTimer) >= $iSleep Then
        If Not $bSuspended Then
            _ProcessSuspend($iExePid)
            $bSuspended = True
        Else
            _ProcessResume($iExePid)
            $bSuspended = False
        EndIf
        If @error Then Exit
        $iTimer = TimerInit()
    EndIf

    If TimerDiff($iTimer2) > 2000 Then
        If Not ProcessExists($iExePid) Then Exit
        $iTimer2 = TimerInit()
    EndIf

WEnd


Func OnExitEvent()
    _ProcessResume($iExePid)
EndFunc


; _ProcessSuspend and _ProcessResume - modified by gil900
Func _ProcessSuspend($processid)
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    Local $i_sucess = DllCall("ntdll.dll", "int", "NtSuspendProcess", "int", $ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If Not IsArray($i_sucess) Then Return SetError(@ScriptLineNumber,0,0)
    Return 1
EndFunc   ;==>_ProcessSuspend

Func _ProcessResume($processid)
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    Local $i_sucess = DllCall("ntdll.dll", "int", "NtResumeProcess", "int", $ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If Not IsArray($i_sucess) Then Return SetError(@ScriptLineNumber,0,0)
    Return 1
EndFunc   ;==>_ProcessResume

 

Edited by gil900
1 person likes this

Share this post


Link to post
Share on other sites



#2 ·  Posted

what is the purpose of running it in slow speed?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

1 hour ago, legend said:

what is the purpose of running it in slow speed?

Testig your code efficiency on bad environment with slow processing speed. But this code specifically will not be good for such testing on second thought..

Edited by gil900

Share this post


Link to post
Share on other sites

#4 ·  Posted

1 hour ago, legend said:

what is the purpose of running it in slow speed?

Testig how your code efficiency on bad environment with slow processing speed. But this code specifically will not be good for such testing on second thought..

 

Edit: 

it is good for saving battery life 

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