Jump to content

Target Screensaver


crashdemons
 Share

Recommended Posts

Here are my statistics between the original download and my posted script.

1.50Ghz (1.49) Intel Pentium 4

384MB RAM

BFG NVidia GeForce 6200 PCI - 256MB

1024x768, 32-bit color

Original Script (Clearing)

New Script (Erasing)

The highest portions of each graph indicate the period running the scripts.

As you can see, the Clearing graph is, on average, much lower than the Erasing for me.

Edit: Screen/PC Info

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Let's benchmark it:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=AITargetting.scr
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=AITargetting Screensaver
#AutoIt3Wrapper_Res_Description=AITargetting Screensaver
#AutoIt3Wrapper_Res_Fileversion=1.3
#AutoIt3Wrapper_Res_LegalCopyright=Crash Daemonicus
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d
#Tidy_Parameters=/rel
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Auto-Targetting Screensaver
;By Crash Daemonicus (crashdemons)
FileInstall('.\move.wav', @ScriptDir & '\move.wav')
FileInstall('.\stop.wav', @ScriptDir & '\stop.wav')
FileInstall('.\target.wav', @ScriptDir & '\target.wav')
FileInstall('.\fakeout.wav', @ScriptDir & '\fakeout.wav')
; The following line is just to suspress extra SyntaxCheck/Au3Check extra Au3Check *warnings* - it's all defined before needed anyway.
Global $hGUI, $ReguMove, $hFormat, $ReguMove, $parent_PID, $child_PID, $ptext, $ptm
#include <Sound.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
Global $Sounds[4] = ['move.wav', 'stop.wav', 'target.wav', 'fakeout.wav']
If WinExists("ScrnSav:" & @ScriptFullPath) Then WinKill("ScrnSav:" & @ScriptFullPath)
AutoItWinSetTitle("ScrnSav:" & @ScriptFullPath)
Global $CL
Local $CmdLinex = StringSplit($CmdLineRaw & ' ', ' '); is CmdLine not defined in later versions if blank or something??
$CL = StringLeft($CmdLinex[1], 2)
If Not @Compiled Then $CL = '/s'
Switch StringTrimLeft($CL, 1)
    Case 's'
        Local $w = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth
        Local $h = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight
        Local $x = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen
        Local $y = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen
        $w = $w[0]
        $h = $h[0]
        $x = $x[0]
        $y = $y[0]
        Init(0, $w, $h, $x, $y, True)
        Local $new, $last
        $d1 = 0
        $d2 = 0
        $c = 0
        $bench_length = 25
        $bench_start = 0        
        While $new >= $last
            $last = $new
            If $c < $bench_length Then
                $bench_start = TimerInit()
                Draw2($w, $h)
                $d2 += TimerDiff($bench_start)
            ElseIf $c >= $bench_length And $c < 2 * $bench_length Then
                $bench_start = TimerInit()
                Draw($w, $h)
                $d1 += TimerDiff($bench_start)
            EndIf
            $c += 1
            If $c > 2 * $bench_length Then 
                ConsoleWrite("Clearing: " & $d1 / $bench_length & " ms (average)" & @CRLF & "Erasing: " &  $d2 / $bench_length & " ms (average)." & @CRLF)
                ExitLoop
            EndIf
            Sleep(100)
            $new = _IdleTicks()
        WEnd
        _Exit()
    Case 'p'
        If $CmdLine[0] < 2 Then
            MsgBox(0, 'AITargetting Screensaver', 'Invalid preview window information supplied.')
            Exit
        EndIf
        Init(HWnd($CmdLine[2]), 152, 112)
        $parent_PID = _ProcessGetParent(@AutoItPID)

        While 1
            If Not WinExists($hGUI) Then _Exit()
            $child_PID = _ProcessGetChildren($parent_PID)
            If $child_PID[0] > 1 Then _Exit() ;if another screensaver is selected in ComboBox close ss
            Draw2(152, 112)
            Sleep(50)
        WEnd
        _Exit()
    Case Else;
        MsgBox(64, 'AITargetting Screensaver', 'Nothing to See here!')
EndSwitch
Exit
Func Init($hWnd, $w, $h, $x = 0, $y = 0, $not_a_preview = False)
    Global $hDC, $gro, $hPen, $hGUI, $grb, $gr, $hPen2, $Sounds
    $hGUI = GUICreate('AITargetting Preview', $w, $h, $x, $y, 0x80000000)
    GUISetBkColor(0, $hGUI)
    WinSetTrans($hGUI, '', 5)
    GUISetState(@SW_SHOW, $hGUI)
    WinSetOnTop($hGUI, '', 1)
    If $not_a_preview Then GUISetCursor(16, 1)
    _WinAPI_SetParent ($hGUI, $hWnd)
    _GDIPlus_Startup ()
    $hDC = _WinAPI_GetDC ($hGUI)
    $gro = _GDIPlus_GraphicsCreateFromHDC ($hDC)
    $grb = _GDIPlus_BitmapCreateFromGraphics ($w, $h, $gro)
    $gr = _GDIPlus_ImageGetGraphicsContext ($grb)
    $hPen = _GDIPlus_PenCreate (0xFF00FF00)
    $hPen2 = _GDIPlus_PenCreate (0xFFFF0000)
    Global $hBrush
    Global $hFormat = _GDIPlus_StringFormatCreate ()
    Global $hFamily = _GDIPlus_FontFamilyCreate ("Lucida Console")
    Global $hFont = _GDIPlus_FontCreate ($hFamily, 8, 2)
    Global $tLayout
;~     _GDIPlus_GraphicsSetSmoothingMode ($gr, 2)
    For $i = 5 To 255 Step 50
        WinSetTrans($hGUI, '', $i); cheap fade-in
    Next
    ;for targetting speed shifts - most of these were tested at 500x500
    Global $FastMove[2] = [Int((40 / 500) * $h), Int((20 / 500) * $h) ]
    Global $SlowMove[2] = [Int((15 / 500) * $h), Int((8 / 500) * $h) ]
    Global $SlowestMove = Int((10 / 768) * $h)
    ;for regular floating
    Global $ReguMove[2] = [Int((1 / 500) * $h), Int((8 / 500) * $h) ]
    Global $target[4] = [Int((200 / 1024) * $w), Int((200 / 768) * $h), $ReguMove[0], $ReguMove[1]]
    Global $goto = False
    Global $XT = TimerInit()
    Global $point
    Global $ptext, $ptm
    Global $TargetTime = 5000
    Global $ifakeout = 0
    Global $ifakeout_max = 1
    For $i = 0 To 3
        If $not_a_preview Then
            $Sounds[$i] = _SoundOpen(@ScriptDir & '\' & $Sounds[$i])
        Else
            $Sounds[$i] = 0
        EndIf
    Next
EndFunc   ;==>Init

Func Draw($w, $h)
    ;since the coordinates drawn here are relative to the GUI Created, the upper-left is always 0,0;
    ; no need to worry about virtual coordinates.
    Global $Sounds, $hBrush, $hFormat, $hFont, $tLayout, $hPen, $hPen2, $gr, $gro, $grb
    Global $FastMove, $SlowMove, $SlowestMove
    Global $target, $goto, $XT, $TargetTime, $ifakeout, $ifakeout_max
    Global $point
    Local $line
    Local $k = Int((20 / 768) * $h)
    Local $k2 = Int((5 / 768) * $h)
    Local $x = $target[0]
    Local $y = $target[1]
    Local $thPen = $hPen
    Local $XTDiff = TimerDiff($XT)
    If (Not $goto) And $XTDiff > $TargetTime Then
        $goto = True
        $target[2] = 0
        $target[3] = 0
        ;$ygoto=True
        Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
        $point = $pointx; shouldn't have to do this.
        $TargetTime = Random(5000, 15000, 1)
        $ifakeout = 0
;~         ConsoleWrite('Target Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
        _SoundPlay($Sounds[2], 0)
        _SoundPlay($Sounds[2], 0)
    EndIf
    If $goto Then
        $thPen = $hPen2
        Local $xdiff = $point[0] - $target[0]
        Local $ydiff = $point[1] - $target[1]
        Local $xdiffa = Abs($xdiff)
        Local $ydiffa = Abs($ydiff)
        If $xdiff <> 0 Then
;~             ConsoleWrite(@TAB & 'Target X ' & $xdiff & @CRLF)
            $target[2] = $xdiff / $xdiffa
            Select
                Case $xdiffa > $FastMove[0]
                    $target[2] *= $FastMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa > $SlowMove[0]
                    $target[2] *= $SlowMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa >= $SlowestMove
                    $target[2] *= $SlowestMove
                    _SoundPlay($Sounds[1], 0)
                Case Else
                    _SoundPlay($Sounds[1], 0)
            EndSelect
        Else
            $target[2] = 0
            If $ydiff <> 0 Then
;~                 ConsoleWrite(@TAB & 'Target Y ' & $ydiff & @CRLF)
                $target[3] = $ydiff / $ydiffa
                Select
                    Case $ydiffa > $FastMove[0]
                        $target[3] *= $FastMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa > $SlowMove[0]
                        $target[3] *= $SlowMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa >= $SlowestMove
                        $target[3] *= $SlowestMove
                        _SoundPlay($Sounds[1], 0)
                    Case Else
                        _SoundPlay($Sounds[1], 0)
                EndSelect
            Else
                If $ifakeout < $ifakeout_max And Random(0, 100, 1) < 40 Then; If there hasn't been $ifakeout_max fake-outs, there will be a 40% chance of getting one.
                    $target[2] = 0
                    $target[3] = 0
                    Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
                    $point = $pointx
                    $ifakeout += 1
;~                     ConsoleWrite('- Target Faked-Out; Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
                    _SoundPlay($Sounds[3], 0)
                Else
;~                     ConsoleWrite('- On Target' & @CRLF)
                    $target[2] = Random($ReguMove[0], $ReguMove[1], 1)
                    $target[3] = Random($ReguMove[0], $ReguMove[1], 1)
                    $goto = False
                    $thPen = $hPen
                    $ptext = '+ 0064089BA72FG'
                    $tLayout = 0
                    $tLayout = _GDIPlus_RectFCreate ($point[0], $point[1], 100, 20)
                    $XT = TimerInit()
                    $ptm = TimerInit()
                    $ifakeout = 0
                    _SoundPlay($Sounds[2], 0)
                EndIf
            EndIf
        EndIf
    EndIf
    _GDIPlus_GraphicsClear ($gr, 0xFF000000)
    _GDIPlus_GraphicsDrawRect ($gr, $x - $k, $y - $k, $k * 2, $k * 2, $thPen);box
    _GDIPlus_GraphicsDrawLine ($gr, $x, 0, $x, $y - $k2, $thPen);top
    _GDIPlus_GraphicsDrawLine ($gr, $x, $y + $k2, $x, $h, $thPen);bottom
    _GDIPlus_GraphicsDrawLine ($gr, 0, $y, $x - $k2, $y, $thPen);left
    _GDIPlus_GraphicsDrawLine ($gr, $x + $k2, $y, $w, $y, $thPen);right
    Local $ptmd = TimerDiff($ptm)
    If $ptmd < 5000 Then
        $hBrush = _GDIPlus_BrushCreateSolid (0xFF000000 + Floor(((5000 - $ptmd) / 5000) * 0xFF) * 0x10000)
        _GDIPlus_GraphicsDrawStringEx ($gr, $ptext, $hFont, $tLayout, $hFormat, $hBrush)
        _GDIPlus_BrushDispose ($hBrush)
    EndIf
    _GDIPlus_GraphicsDrawImageRect ($gro, $grb, 0, 0, $w, $h) ;copy to bitmap
    $target[0] += $target[2]
    $target[1] += $target[3]
    iLimit($target[0], $k, $w - $k)
    If @error Then $target[2] *= -1
    iLimit($target[1], $k, $h - $k)
    If @error Then $target[3] *= -1
EndFunc   ;==>Draw

Func Draw2($w, $h)
    ;since the coordinates drawn here are relative to the GUI Created, the upper-left is always 0,0;
    ; no need to worry about virtual coordinates.
    Global $Sounds, $hBrush, $hFormat, $hFont, $tLayout, $hPen, $hPen2, $gr, $gro, $grb
    Global $FastMove, $SlowMove, $SlowestMove
    Global $target, $goto, $XT, $TargetTime, $ifakeout, $ifakeout_max
    Global $point
    Local $line
    Local $k = Int((20 / 768) * $h)
    Local $k2 = Int((5 / 768) * $h)
    Local $x = $target[0]
    Local $y = $target[1]
    Local $thPen = $hPen
    Local $XTDiff = TimerDiff($XT)
    If (Not $goto) And $XTDiff > $TargetTime Then
        $goto = True
        $target[2] = 0
        $target[3] = 0
        ;$ygoto=True
        Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
        $point = $pointx; shouldn't have to do this.
        $TargetTime = Random(5000, 15000, 1)
        $ifakeout = 0
;~         ConsoleWrite('Target Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
        _SoundPlay($Sounds[2], 0)
        _SoundPlay($Sounds[2], 0)
    EndIf
    If $goto Then
        $thPen = $hPen2
        Local $xdiff = $point[0] - $target[0]
        Local $ydiff = $point[1] - $target[1]
        Local $xdiffa = Abs($xdiff)
        Local $ydiffa = Abs($ydiff)
        If $xdiff <> 0 Then
;~             ConsoleWrite(@TAB & 'Target X ' & $xdiff & @CRLF)
            $target[2] = $xdiff / $xdiffa
            Select
                Case $xdiffa > $FastMove[0]
                    $target[2] *= $FastMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa > $SlowMove[0]
                    $target[2] *= $SlowMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa >= $SlowestMove
                    $target[2] *= $SlowestMove
                    _SoundPlay($Sounds[1], 0)
                Case Else
                    _SoundPlay($Sounds[1], 0)
            EndSelect
        Else
            $target[2] = 0
            If $ydiff <> 0 Then
;~                 ConsoleWrite(@TAB & 'Target Y ' & $ydiff & @CRLF)
                $target[3] = $ydiff / $ydiffa
                Select
                    Case $ydiffa > $FastMove[0]
                        $target[3] *= $FastMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa > $SlowMove[0]
                        $target[3] *= $SlowMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa >= $SlowestMove
                        $target[3] *= $SlowestMove
                        _SoundPlay($Sounds[1], 0)
                    Case Else
                        _SoundPlay($Sounds[1], 0)
                EndSelect
            Else
                If $ifakeout < $ifakeout_max And Random(0, 100, 1) < 40 Then; If there hasn't been $ifakeout_max fake-outs, there will be a 40% chance of getting one.
                    $target[2] = 0
                    $target[3] = 0
                    Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
                    $point = $pointx
                    $ifakeout += 1
;~                     ConsoleWrite('- Target Faked-Out; Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
                    _SoundPlay($Sounds[3], 0)
                Else
;~                     ConsoleWrite('- On Target' & @CRLF)
                    $target[2] = Random($ReguMove[0], $ReguMove[1], 1)
                    $target[3] = Random($ReguMove[0], $ReguMove[1], 1)
                    $goto = False
                    $thPen = $hPen
                    $ptext = '+ 0064089BA72FG'
                    $tLayout = 0
                    $tLayout = _GDIPlus_RectFCreate ($point[0], $point[1], 100, 20)
                    $XT = TimerInit()
                    $ptm = TimerInit()
                    $ifakeout = 0
                    _SoundPlay($Sounds[2], 0)
                EndIf
            EndIf
        EndIf
    EndIf
   
    For $i=0 To 1
;~         _GDIPlus_GraphicsClear ($gr, 0xFF000000)
        _GDIPlus_GraphicsDrawRect ($gr, $x - $k, $y - $k, $k * 2, $k * 2, $thPen);box
        _GDIPlus_GraphicsDrawLine ($gr, $x, 0, $x, $y - $k2, $thPen);top
        _GDIPlus_GraphicsDrawLine ($gr, $x, $y + $k2, $x, $h, $thPen);bottom
        _GDIPlus_GraphicsDrawLine ($gr, 0, $y, $x - $k2, $y, $thPen);left
        _GDIPlus_GraphicsDrawLine ($gr, $x + $k2, $y, $w, $y, $thPen);right
        Local $ptmd = TimerDiff($ptm)
        If $i=0 Then
            If $ptmd < 5000 Then
                $hBrush = _GDIPlus_BrushCreateSolid (0xFF000000 + Floor(((5000 - $ptmd) / 5000) * 0xFF) * 0x10000)
                _GDIPlus_GraphicsDrawStringEx ($gr, $ptext, $hFont, $tLayout, $hFormat, $hBrush)
                _GDIPlus_BrushDispose ($hBrush)
            EndIf
            _GDIPlus_GraphicsDrawImageRect ($gro, $grb, 0, 0, $w, $h);copy to bitmap
            $thPen=0; overwrite black next loop
        Else
            If $ptmd < 5000 Then _GDIPlus_GraphicsFillRect($gr,$point[0],$point[1],100,20)
        EndIf
    Next
   
   
    $target[0] += $target[2]
    $target[1] += $target[3]
    iLimit($target[0], $k, $w - $k)
    If @error Then $target[2] *= -1
    iLimit($target[1], $k, $h - $k)
    If @error Then $target[3] *= -1
EndFunc  ;==>Draw
Func iLimit($i, $n, $x)
    If $i >= $n And $i <= $x Then Return $i
    If $i < $n Then
        SetError(1)
        Return $n
    EndIf
    If $i > $x Then
        SetError(2)
        Return $x
    EndIf
EndFunc   ;==>iLimit
Func _Exit()
    Global $Sounds, $tLayout, $hFont, $hFamily, $hPen, $hPen2, $gr, $grb, $gro, $hDC
    For $i = 0 To 3
        _SoundClose($Sounds[$i])
    Next
    $tLayout = 0
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_PenDispose ($hPen2)
    _GDIPlus_GraphicsDispose ($gr)
    _GDIPlus_BitmapDispose ($grb)
    _GDIPlus_GraphicsDispose ($gro)
    _WinAPI_ReleaseDC (0, $hDC)
    Exit
EndFunc   ;==>_Exit
#Region OtherRequiredFuncs
Func _IdleTicks() ; thanks to erifash for the routine
    Local $aTSB = DllCall("kernel32.dll", "long", "GetTickCount")
    Local $ticksSinceBoot = $aTSB[0]
    Local $struct = DllStructCreate("uint;dword")
    DllStructSetData($struct, 1, DllStructGetSize($struct))
    DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))
    Local $ticksSinceIdle = DllStructGetData($struct, 2)
    Return ($ticksSinceBoot - $ticksSinceIdle)
EndFunc   ;==>_IdleTicks
Func _ProcessGetParent($i_pid) ;get PID from parent process done by SmOke_N
    Local $TH32CS_SNAPPROCESS = 0x00000002
    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)
    Local $tagPROCESSENTRY32 = _
            DllStructCreate( _
            "dword dwsize;" & _
            "dword cntUsage;" & _
            "dword th32ProcessID;" & _
            "uint th32DefaultHeapID;" & _
            "dword th32ModuleID;" & _
            "dword cntThreads;" & _
            "dword th32ParentProcessID;" & _
            "long pcPriClassBase;" & _
            "dword dwFlags;" & _
            "char szExeFile[260]" _
            )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)
    Local $a_pnext, $i_return = 0
    If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
        $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
        DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
        If $i_return Then Return $i_return
        Return $i_pid
    EndIf
    While @error = 0
        $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
        If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
            $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
            If $i_return Then ExitLoop
            $i_return = $i_pid
            ExitLoop
        EndIf
    WEnd
    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    Return $i_return
EndFunc   ;==>_ProcessGetParent
Func _ProcessGetChildren($i_pid) ; First level children processes only done by SmOke_N
    Local Const $TH32CS_SNAPPROCESS = 0x00000002
    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)
    Local $tagPROCESSENTRY32 = _
            DllStructCreate _
            ( _
            "dword dwsize;" & _
            "dword cntUsage;" & _
            "dword th32ProcessID;" & _
            "uint th32DefaultHeapID;" & _
            "dword th32ModuleID;" & _
            "dword cntThreads;" & _
            "dword th32ParentProcessID;" & _
            "long pcPriClassBase;" & _
            "dword dwFlags;" & _
            "char szExeFile[260]" _
            )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)
    Local $a_pnext, $a_children[11] = [10], $i_child_pid, $i_parent_pid, $i_add = 0
    $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
    If $i_child_pid <> $i_pid Then
        $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
        If $i_parent_pid = $i_pid Then
            $i_add += 1
            $a_children[$i_add] = $i_child_pid
        EndIf
    EndIf
    While 1
        $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
        If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop
        $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
        If $i_child_pid <> $i_pid Then
            $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
            If $i_parent_pid = $i_pid Then
                If $i_add = $a_children[0] Then
                    ReDim $a_children[$a_children[0] + 10]
                    $a_children[0] = $a_children[0] + 10
                EndIf
                $i_add += 1
                $a_children[$i_add] = $i_child_pid
            EndIf
        EndIf
    WEnd
    If $i_add <> 0 Then
        ReDim $a_children[$i_add + 1]
        $a_children[0] = $i_add
    EndIf
    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    If $i_add Then Return $a_children
    Return SetError(3, 0, 0)
EndFunc   ;==>_ProcessGetChildren
#EndRegion OtherRequiredFuncs

My results:

Clearing: 87.7527367305063 ms (average)

Erasing: 36.8857690013675 ms (average).

My hardware:

Latitude D830

Intel® Core2 Duo CPU T7300 @ 2.00GHz / x64 Family 6 Model 15 Stepping 10

2GB memory

NVIDIA Quadro NVS 140M

1920x1200 @ 32bit

Vista x32

AutoIt v3.3.0.0

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Bench length 500:

Clearing: 70.4056030864258 ms (average)

Erasing: 63.0122394047289 ms (average).

I think that depends on hw...

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

So, what does this benchmark show us?

- that I could substitute the drawing method that works good for me for the one that works good for you? :P

I'm not sure.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Bench length 500:

Clearing: 70.4056030864258 ms (average)

Erasing: 63.0122394047289 ms (average).

I think that depends on hw...

UEZ

The new download (1.5) now supports a configuration window so you can set your own Draw Mode (Clear or Erase) and Frame Delay.

More customizations planned in the future.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

  • 4 weeks later...

Does the above posted update solve most of the issues with the script that you have?

(eg. the drawing mode selection)

By the Way:

Can anyone figure out which game or movie has this type of targeting thing in the credits sequence?

(the one I'm using in my screensaver)

If I recall correctly it had a blue/gray tint and had a lot of text/things moving in the background while the target was moving and locking-in on particular developer names.

I don't really want to play/see all of the games and movies again to find out.

Somehow I doubt it was a movie, though.

This list may help narrow the possibilities of which media influence this...

*(?) Possibility

x(?) Not a Possibility

Games->

  • * Burnout Revenge
  • x Constantine
  • x Conker L&R
  • x Doom 3 (& RoE)
  • x? Enter the Matrix
  • x Far Cry: Instincts Evolution
  • x Half-Life 2 checked
  • x Halo 1/2
  • x The Matrix: The Path of Neo
  • x Metal Gear Solid 2: Substance checked
  • * Pariah
  • x Prince of Persia SoT/WW/TT
  • x? Star Wars: Obi-Wan
  • *? TimeSplitters: Future Perfect

I won't bother adding older games like Twisted Metal 1-4

(although they ARE classic games that I will always remember :D )

Movies->

  • x Lost In Space (newer)
  • x Matrix 1-3
  • * Minority Report
  • * Artificial Intelligence
  • * The 6th Day (yes, don't laugh)
  • x various Star Trek's
  • x Iron Man checked
  • ... etc.

If you can figure out which one has the target in the credits, let us know.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

  • 1 month later...

the game credits it is from is super smash brothers (i think) for the n64

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Can't be what I was thinking of, as I have never played super smash brothers and I don't own an N64 :)

I'll have to re-check the credits for Metal Gear S2 and Pariah sometime.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

How about the movie with Gene Hackman and Will Smith? I don't know the original name (Enemy of the State?)...

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Don't think I've seen it.

Don't worry about it - I'll re-play some of the things I have when I get a chance.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Currently I have a problem with the script where if Erasing mode is being used, the draw time (But not the erase time!) grows exponentially beginning at the first "lock-on."

I narrowed it to the lock-on because when I changed the script to never lock-on, the draw time did not grow significantly.

I will have to investigate the source of this leak, but it's already got me confused :)

Erase times throughout use:

Draw Time: 35.8674077291946
Erase Time: 4.11756242762697
...
Draw Time: 26.2024922161895
Erase Time: 3.71443856691283
...
Draw Time: 37.7011603430045
Erase Time: 3.97452748882889
***Target Point (714,585)
    Target X 479
Draw Time: 36.8046776894829
Erase Time: 3.71332110645347
...
    Target X 359
Draw Time: 72.8922251291714
Erase Time: 3.96921955164693
...
    Target X 119
Draw Time: 128.873641761732
Erase Time: 3.72393698081739
...
    Target Y -35
Draw Time: 144.150443701644
Erase Time: 3.56860997696635

("..." indicates a where I cut out changes over time)

Debug version of script (See SciTE console after the screensaver closes)

AITargetting.au3

"Target Point" in the console is when the "lock-on" occurs; The config window will also allow disabling "lock-ons"

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Something in the below code is slowing the draw process during erase mode. (and it's not the ugliness of it!)

If $goto Then
        $thPen = $hPen2
        Local $xdiff = $point[0] - $target[0]
        Local $ydiff = $point[1] - $target[1]
        Local $xdiffa = Abs($xdiff)
        Local $ydiffa = Abs($ydiff)
        If $xdiff <> 0 Then
            ConsoleWrite(@TAB & 'Target X ' & $xdiff & @CRLF)
            $target[2] = $xdiff / $xdiffa
            Select
                Case $xdiffa > $FastMove[0]
                    $target[2] *= $FastMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa > $SlowMove[0]
                    $target[2] *= $SlowMove[1]
                    _SoundPlay($Sounds[0], 0)
                Case $xdiffa >= $SlowestMove
                    $target[2] *= $SlowestMove
                    _SoundPlay($Sounds[1], 0)
                Case Else
                    _SoundPlay($Sounds[1], 0)
            EndSelect
        Else
            $target[2] = 0
            If $ydiff <> 0 Then
                ConsoleWrite(@TAB & 'Target Y ' & $ydiff & @CRLF)
                $target[3] = $ydiff / $ydiffa
                Select
                    Case $ydiffa > $FastMove[0]
                        $target[3] *= $FastMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa > $SlowMove[0]
                        $target[3] *= $SlowMove[1]
                        _SoundPlay($Sounds[0], 0)
                    Case $ydiffa >= $SlowestMove
                        $target[3] *= $SlowestMove
                        _SoundPlay($Sounds[1], 0)
                    Case Else
                        _SoundPlay($Sounds[1], 0)
                EndSelect
            Else
                If $ifakeout < $ifakeout_max And Random(0, 100, 1) < 40 Then; If there hasn't been $ifakeout_max fake-outs, there will be a 40% chance of getting one.
                    $target[2] = 0
                    $target[3] = 0
                    Local $pointx[2] = [Random($k, $w - $k, 1), Random($k, $h - $k, 1) ]
                    $point = $pointx
                    $ifakeout += 1
                    ConsoleWrite('- Target Faked-Out; Point (' & $point[0] & ',' & $point[1] & ')' & @CRLF)
                    _SoundPlay($Sounds[3], 0)
                Else
                    ConsoleWrite('- On Target' & @CRLF)
                    $target[2] = Random($ReguMove[0], $ReguMove[1], 1)
                    $target[3] = Random($ReguMove[0], $ReguMove[1], 1)
                    $goto = False
                    $thPen = $hPen
                    $ptext = '+ 0064089BA72FF'
                    $tLayout = 0
                    $tLayout = _GDIPlus_RectFCreate ($point[0], $point[1], 100, 20)
                    $XT = TimerInit()
                    $ptm = TimerInit()
                    $ifakeout = 0
                    _SoundPlay($Sounds[2], 0)
                EndIf
            EndIf
        EndIf
    EndIf

Things I tried, failing:

Disabling the drawing of text and assignment of $tLayout

Commenting out all of the _SoundPlay's

Keeping the temporary pen from changing colors.

Notes: if DoLockOn=0 or Goto=False and a lock-on drawing never occurs, the drawing does not slow down.

Perhaps the multiplication or calls to Random() slow it down, but what wouldn't be specific to erase-mode; none of this would.

It seems strange that this segment causes issues because of it's relatively irrelevance to the actual drawing. (only the font rect, pen, and text is passed besides target positions)

Yet, removing it also removes the problem.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

My investigations into the draw time in erasing mode has yielded no reasons why the draw time increases.

(note: this is the time it takes ONLY the GDI+ functions to complete, NOT the calculations!)

All I can say is this: In erasing mode, if element 2 or 3 of the $target array are changed (eg: within If $goto Then ...) then the draw time increases exponentially. If the values are never changed or are only changed for a few large jumps, the draw time stays low. (truly odd, since they only modify drawing positions on the FOLLOWING pass!)

The circumstances surrounding the draw time while erasing seem completely illogical to me - which, this being a program, could only logically mean I'm missing something.

Another oddity, the graphics object attached to the bitmap buffer seems to hold more association with the drawing rather than just the color and alpha value - I'll explain this:

If I do as I am and make drawings to the buffer as normal but do not call _GraphicsClear, the drawing time increases.

However, if I even call _GraphicsClear with a color of 0x00000000 (transparent - has no effect on the image in the buffer), the drawing time returns to normal. This implies that something was changed besides image data by calling GraphicsClear.

:)

Perhaps I am missing some important fact here about GDI+; would anyone care to enlighten me about why drawing a line 1px from where it was takes 10 times longer than drawing it 30px from where it was when it's already been drawn over in black in the previous pass? (rather than cleared, which works fine)

I just cannot make sense of this particular issue and I've racked my brain for several days now.

I'm a little out of options as failing to call GraphicsClear seems to be the wrong thing to do - and calling it on large dimensions is inefficient.

:party:

@ UEZ, hey - you're the GDI+ master lol, want to take a crack at it?

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

  • 7 months later...

Not to bump this old thread, but I did finally figure out what had the credits with the target like this one:

Pariah the video game. (XBX)

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

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...