Leaderboard
Popular Content
Showing content with the highest reputation on 09/12/2014 in all areas
-
Can't you do something like this, without calculating that average thing: ;... ;Loop for approx one second $Timer = TimerInit() While TimerDiff($Timer) <= $OneSecond $hAnotherTimer = TimerInit() $Cap = _ScreenCapture_Capture($CaptureFolder & $Iterator & ".bmp", 0, 0, 100, 100) ;Just for file name $Iterator += 1 Sleep(1000 / $AimFrames - TimerDiff($hAnotherTimer)) WEnd ;...2 points
-
Yes, I tried to optimize the code by embedding _ScreenCapture_Capture() directly and removed unneeded lines. Looks complicated but it is the price you pay when you try to optimize the code. Br, UEZ1 point
-
You might be able to optimize the UDF functions by removing any code which is not needed for your specific task. I sometimes remove error checks (and conditional statements) that are not needed because I know exactly what I'm feeding into a function. Fine tuning is sometimes the only way to go!1 point
-
Locking Computer
232showtime reacted to Bert for a topic
I know what you could do....Have a script running that puts up a splash screen that fills the entire screen. The only way to hide it is to put in your USB stick. WHen the script sees the stick, it hides the splash screen. You remove the stick, it puts the splash screen back. This is not 100% secure for CTRL-ALT-DEL can close the script but you have to know what your doing. May I ask however - why not simply use the Windows key +L to lock the workstation when you leave the workstation and then use your password to get back in when you come back. Pretty much everyone else does that and it works great.1 point -
Mod() is sometimes a good function for this kind of thing. ; HotKeySet('{ESC}', '_exit') Local $aArray[3] = ["Have a nice day!", "Tacos taste good.", "Shrek is love!"], _ $i = 0 While True Send($aArray[Mod($i, 3)] & @CR, 1) $i += 1 ; This value will eventually go out of range (> 99999999999999). WEnd Func _exit() Exit EndFunc ;==>_exit ; Theoretically the code will stop working because the variable $i will eventually go out of range. It probably won't happen within a milenium: because the Send function is really slow. If the looped process is millions of times faster, then out of range values could become a problem, in which case the code will need to be ammended.1 point
-
That's because the $TargetFramesPerSecond is set to 15, change that number, update the _AvarageScreenshotTime function to not save the files either, and I can get around 50-55 frames taken in one second. Func _AvarageScreenshotTime($NunShots) Local $aShots[$NunShots] For $I = 0 To $NunShots - 1 $Timer = TimerInit() _ScreenCapture_Capture("", 0, 0, 100, 100) ; don't save the screen shots $Diff = TimerDiff($Timer) $aShots[$I] = $Diff Next ;~ FileDelete("pic.bmp") $Total = 0 For $I = 0 To $NunShots - 1 $Total += ($aShots[$I]) Next $average = $Total / $NunShots Return Floor($average) EndFunc ;==>_AvarageScreenshotTime1 point
-
Well, I had the same problem when I created the feature to capture the screen to an avi file in Windows Screenshooter. I used this technique (function Grab2AVI()) to get as close as possible to the fps: ... Local $hBitmap_AVI, $hBitmap_AVI_TS, $hBmp_AVI_TS, $OldBMP Local $iLeft, $iRight, $iTop, $iBottom Local $hIcon, $aIcon Local $tCursor, $tInfo, $iCursor, $aCursor[5], $aIcon[6] Local $total_FPS = $rec_time * $fps, $fps_c = 1 Local $bInfinity = False If $rec_time = "Endless" Then $bInfinity = True $total_FPS = 0xFFFFFF EndIf Local Const $fc = 1000 / $fps Local Const $k32_dll = DllOpen("kernel32.dll") Local Const $u32_dll = DllOpen("user32.dll") Local Const $DC = _WinAPI_GetDC(0) Local Const $hDC = _WinAPI_CreateCompatibleDC($DC) ... Do $t = TimerInit() ;_ScreenCapture_Capture() reduced $OldBMP = DllCall($g32_dll, "handle", "SelectObject", "handle", $hDC, "handle", $hBmp_AVI) ;_WinAPI_SelectObject() DllCall($g32_dll, "bool", "BitBlt", "handle", $hDC, "int", 0, "int", 0, "int", $iW, "int", $iH, "handle", $DC, "int", $iLeft, "int", $iTop, "dword", $SRCCOPY) ;_WinAPI_BitBlt() If $cursor Then $tCursor = DllStructCreate($tagCURSORINFO) $iCursor = DllStructGetSize($tCursor) DllStructSetData($tCursor, "Size", $iCursor) DllCall($u32_dll, "bool", "GetCursorInfo", "ptr", DllStructGetPtr($tCursor)) $aCursor[1] = DllStructGetData($tCursor, "Flags") <> 0 $aCursor[2] = DllStructGetData($tCursor, "hCursor") $aCursor[3] = DllStructGetData($tCursor, "X") $aCursor[4] = DllStructGetData($tCursor, "Y") If $aCursor[1] Then $hIcon = DllCall($u32_dll, "handle", "CopyIcon", "handle", $aCursor[2]) $tInfo = DllStructCreate($tagICONINFO) DllCall($u32_dll, "bool", "GetIconInfo", "handle", $hIcon[0], "ptr", DllStructGetPtr($tInfo)) $aIcon[2] = DllStructGetData($tInfo, "XHotSpot") $aIcon[3] = DllStructGetData($tInfo, "YHotSpot") $aIcon[4] = DllStructGetData($tInfo, "hMask") DllCall($g32_dll, "bool", "DeleteObject", "handle", $aIcon[4]) DllCall($u32_dll, "bool", "DrawIcon", "handle", $hDC, "int", $aCursor[3] - $aIcon[2] - $iLeft, "int", $aCursor[4] - $aIcon[3] - $iTop, "handle", $hIcon[0]) DllCall($u32_dll, "bool", "DestroyIcon", "handle", $hIcon[0]) EndIf EndIf DllCall($g32_dll, "int", "GetDIBits", "handle", $hDC, "handle", $hBmp_AVI, "uint", 0, "uint", $iLines, "ptr", $pBits, "ptr", $pHeader, "uint", 0) ;_WinAPI_GetDIBits() DllCall($g32_dll, "handle", "SelectObject", "handle", $hDC, "handle", $OldBMP[0]) ;_WinAPI_SelectObject() DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $AVI_File[1], "long", $AVI_File[2], "long", 1, "ptr", $pBits, "long", $iSize, "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0) $AVI_File[2] += 1 If Not $bInfinity Then $fps_c += 1 EndIf $td = $fc - TimerDiff($t) If $td > 0 Then DllCall($k32_dll, "none", "Sleep", "dword", $td) EndIf If $fps_c > $total_FPS Or $end_avi_cap Then ExitLoop EndIf Until False ... Br, UEZ1 point
-
But that's overcomplicating. Both of the examples can be reduced to: While True Send("Have a nice day!") Send("Tacos taste good.") Send("Shrek is love!") WEnd Somehow I think that's not what the OP meant.1 point
-
your way takes nearly always 15 frames per second. just wondering if in that way all frames are buffered in memory? if so, will this limits the total amount of seconds of the whole "movie" or this problem will be managed by the system?1 point
-
try Return $average instead of Return Floor($average) and it should shot 15 frames above is to be forgotten edit: ..... not always ....... ?1 point
-
Here's a much better option, instead of saving the files every time through the loop, get the $hBMP handle and store it in an array. After you've taken all of your screen shots, then save them all to disk, this way the function doesn't have to waste time saving files before returning and can return as soon as possible. #include <Screencapture.au3> #include <File.au3> ;Create a temp folder in script dir if it does not exist Const $CaptureFolder = @ScriptDir & "\capture\" If Not FileExists($CaptureFolder) Then DirCreate($CaptureFolder) EndIf ;Some variables Const $OneSecond = 1000 Const $TargetFramesPerSecond = 15 $Iterator = 0 ;Some Calculations. $AvaerageShoTime = _AvarageScreenshotTime(200) $Calc1 = $AvaerageShoTime * $TargetFramesPerSecond $Calc2 = 1000 - $Calc1 $Sleep = $Calc2 / $TargetFramesPerSecond ;Loop for approx one second $Timer = TimerInit() Global $aCap[1000] While TimerDiff($Timer) <= $OneSecond $aCap[$Iterator] = _ScreenCapture_Capture("", 0, 0, 100, 100) ;Just for file name $Iterator += 1 Sleep($Sleep) WEnd ReDim $aCap[$Iterator] For $I = 0 To UBound($aCap) - 1 _ScreenCapture_SaveImage($CaptureFolder & $I & ".bmp", $aCap[$I]) Next $aFiles = _FileListToArray($CaptureFolder, "*.bmp", 1) If @error Then ;Remove files and folders _RemoveDir() Exit MsgBox(0, 0, "Error") EndIf ;Amount of images created $CURRENT_FPS = Int($aFiles[0]) MsgBox(0, "Files", "Captured " & $CURRENT_FPS & " images in 1 second") _RemoveDir() Func _RemoveDir() FileDelete($CaptureFolder & "*") For $I = 1 To 10 $Removed = DirRemove($CaptureFolder) If $Removed Then ExitLoop EndIf Sleep(100) Next MsgBox(0, "Removed Folder", ($Removed = 1)) EndFunc ;==>_RemoveDir Func _AvarageScreenshotTime($NunShots) Local $aShots[$NunShots] For $I = 0 To $NunShots - 1 $Timer = TimerInit() _ScreenCapture_Capture("pic.bmp", 0, 0, 100, 100) $Diff = TimerDiff($Timer) $aShots[$I] = $Diff Next FileDelete("pic.bmp") $Total = 0 For $I = 0 To $NunShots - 1 $Total += ($aShots[$I]) Next $average = $Total / $NunShots Return Floor($average) EndFunc ;==>_AvarageScreenshotTime You'll have to adjust your averagescreenshotime function to accomodate that method. I've gotten up to 50+ screenshots using this, and as low as 40.1 point
-
Maybe it would be better to rapid fire as many screenshots as possible, and then logically delete some of the files until you get 20 fps. Then, you don't have to worry about timing averages, which will never be consistent enough to do anything with. #include <ScreenCapture.au3> #include <File.au3> $iTimer=TimerInit() $i = 1 While TimerDiff($iTimer)<1000 _ScreenCapture_Capture(@DesktopDir & "\screenshots\" & $i & ".bmp",0,0,100,100) $i+=1 WEnd $aFiles = _FileListToArray(@DesktopDir & "\screenshots\") $iTotal = UBound($aFiles)-1 $iDelete = $iTotal-20 If $iTotal/$iDelete > 2 Then $iDeleteSkips = Int($iTotal/$iDelete) ConsoleWrite($iTotal & " " & $iDelete & " " & $iDeleteSkips & @CRLF) For $i = $iDeleteSkips+1 To UBound($aFiles)-1 Step $iDeleteSkips FileDelete(@DesktopDir & "\screenshots\" & $i & ".bmp") Next EndIf super simple example...more cacluations are required to get exactly any amount of screenshots.1 point
-
Adlib to frame period will be more robust.1 point
-
it should be: calculate the time taken by one sccreenshot then multiply that time for the number of screenshots you want to take in one second then subtract from 1000 the result of the above calc and you get the spare time (total idle time) now divide the spare time for each screenshot and sleep for the resulting time (between each screenshot)1 point
-
@JohnOne: You can do something like this here: $iFPS = 20 $fDelay = 1000 / $iFPS $iSeconds = 1 $iMaxFrames = $iSeconds * $iFPS $iCounter = 0 $iTimer = TimerInit() Do If TimerDiff($iTimer) > $fDelay Then ConsoleWrite("Took a screenshot" & @CRLF) $iTimer = TimerInit() $iCounter += 1 EndIf Until $iCounter = $iMaxFrames ConsoleWrite("Captured " & $iCounter & " frames" & @CRLF) Br, UEZ1 point
-
Oh! My calc be operate in HEX! Not DEC! This is error! asohaoshaos1 point
-
Sleep(x) is sleep(x) regardless of your machine. As BrewManNH said to take screenshots it takes some milliseconds. Br, UEZ1 point
-
Actually 1000/20 = 50, not 80. You'd also need to build into the delay the time it takes to actually take the screenshot, and subtract that from the 50. So if it takes 5ms to take the screen shot, you'd want to delay 45ms, that way it will sleep for 45, take the screen shot, sleep for another 45 lather/rinse/repeat.1 point
-
1000 / 20 = 80 1000 / 20 = 50 -> 20 frames every 50 milliseconds. Br, UEZ1 point
-
1 second have 1000 mili seconds. If you have 20 frames per second, just 1000 / 20 = 80. (if you use HEX calc). If you have 20 frames per second, just 1000 / 20 = 50. (if you use DEC calc). AdLibRegister("takeshot", 50) Maybe this??1 point
-
This script sets the background color of item 5 to a dark blue and writes @error = 0 to the SciTE console. Tested with PP 2010. $oPPT = ObjCreate("PowerPoint.Application") If @error Then Exit MsgBox(0, "Error", "No PowerPoint available") AddSlide(2, 11, "Example Project") MsgBox(0, "Information", "Test ended.") Func AddSlide($slideNum, $format, $projectName) $oPresentation = $oPPT.Presentations.Open(@ScriptDir & "\Test.potx") If @error Then Exit MsgBox(0, "Error", "Error opening potx") $rows = 10 $cols = 3 $oSlide1 = $oPresentation.Slides.Add($slideNum, $format) With $oSlide1 .Shapes.Item(1).TextFrame.TextRange.Text = $projectName .Shapes.AddTextBox(1, 35, 60, 400, 50) ;type,left,top,width,height .Shapes.Item(2).TextFrame.TextRange.Text = "Overall Status" .Shapes.AddTextBox(1, 300, 60, 400, 50) .Shapes.Item(3).TextFrame.TextRange.Text = "Issues" .Shapes.AddTextBox(1, 500, 60, 400, 50) .Shapes.Item(4).TextFrame.TextRange.Text = "Next Week" .Shapes.AddShape(151, 30, 100, 200, 200) .Shapes.Item(6).Fill.ForeColor.RGB = 0xff0000 ; RGB(255, 0, 0) ConsoleWrite("@error = " & @error & @CRLF) .Shapes.AddTable($rows, $cols, 60, 120, 100, 100) EndWith EndFunc ;==>AddSlide1 point
-
. Clearly understood JLogan3o13 thanks for all the effort - sincerely.1 point