Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/05/2013 in all areas

  1. Beekman, As you have it, but without the trailing "." after Exit. M23
    1 point
  2. It's going to do that because you're updating the listview quickly in the loop. Here's a way to hide the process, yet still let the user know it's working in the background. Here's your script modified with a function I created that will do that for you, the lines added have all been marked in the code. #NoTrayIcon #include <GUILIstview.au3> ; <<<<<<<<<<<< added Opt("GUIOnEventMode", 1) Global $Lister[9999][2] $COUNT = 0 ;~ $LVM_SETCOLUMNWIDTH = (4096 + 30) ; <<<<<<<<<< not needed now $Form1 = GUICreate("Hello " & @ComputerName, 609, 480, 302, 273) GUISetOnEvent(-3, "__Exit") $Tab1 = GUICtrlCreateTab(8, 49, 593, 393) $TabSheet1 = GUICtrlCreateTabItem(" Liste proxy ") $ListView1 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150) $settings = GUICtrlCreateContextMenu($ListView1) $SENDS = GUICtrlCreateMenuItem("add to favoris", $settings) GUICtrlSetOnEvent(-1, "add") $Checkbox1 = GUICtrlCreateCheckbox("Use a proxy", 104, 8, 97, 17) GUICtrlSetOnEvent(-1, "Checkbox") $Checkbox2 = GUICtrlCreateCheckbox("Rendom proxy", 104, 24, 97, 17) GUICtrlSetState(-1, 129) $Checkbox3 = GUICtrlCreateCheckbox("Bypass proxy server for local addresses", 224, 8, 217, 17) GUICtrlSetState(-1, 129) $TabSheet2 = GUICtrlCreateTabItem(" favoris ") $ListView2 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150) GUICtrlCreateTabItem("") $Button1 = GUICtrlCreateButton("Set proxy", 8, 8, 75, 33) GUICtrlSetOnEvent(-1, "SELECTED") $Label1 = GUICtrlCreateLabel("", 16, 453, 111, 17) $Label2 = GUICtrlCreateLabel("", 133, 453, 464, 17) $Group1 = GUICtrlCreateGroup("", 8, 440, 593, 33) GUISetState() GETPROXY() Do Sleep(10000) Until False Func __Exit() Exit EndFunc ;==>__Exit Func _DownloadProgress($FileURL, $FileSave) $FileSize = InetGetSize($FileURL) If $FileSize = 0 Then Return 404 $FileDownload = InetGet($FileURL, $FileSave, 0, 1) Do $Percentage = InetGetInfo($FileDownload, 0) * 100 / $FileSize GUICtrlSetData($Label1, "Please wait ... " & Round($Percentage, 0) & " % ") Sleep(200) Until InetGetInfo($FileDownload, 2) EndFunc ;==>_DownloadProgress Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1) Local $s_case = "" If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)" Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1") $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1") If $s_Start = "" Then $s_Start = "\A" If $s_End = "" Then $s_End = "\z" Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3) If @error Then Return SetError(1, 0, 0) Return $a_ret EndFunc ;==>_StringBetween Func add() $selected = GUICtrlRead(GUICtrlRead($ListView1)) If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then GUICtrlSetData($Label2, "") Return ElseIf Not $selected <> "" Then GUICtrlSetData($Label2, "Please select proxy first.") Return EndIf $StringSplit = StringSplit($selected, "|", 1) GUICtrlCreateListViewItem($StringSplit[1] & "|" & $StringSplit[2] & "|" & $StringSplit[3] & "|" & $StringSplit[4], $ListView2) EndFunc ;==>add Func Checkbox() If GUICtrlRead($Checkbox1) = 1 Then GUICtrlSetState($Checkbox2, 64) GUICtrlSetState($Checkbox3, 64) Else GUICtrlSetState($Checkbox2, 128) GUICtrlSetState($Checkbox3, 128) EndIf EndFunc ;==>Checkbox Func favo() $selected = GUICtrlRead(GUICtrlRead($ListView2)) If Not $selected <> "" Then GUICtrlSetData($Label2, "Please select proxy first.!!!") Return EndIf $StringSplit = StringSplit($selected, "|", 1) $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1) $ping = Ping($IP, 9999) GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1]) DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) EndFunc ;==>favo Func GETPROXY() ;~ RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) GUICtrlSetData($Label1, "Please wait ...") $FileURL1 = "http://www.proxylists.net/proxylists.xml" $FileName1 = @TempDir & "\proxylists" $Down = _DownloadProgress($FileURL1, $FileName1) If $Down = 404 Then GUICtrlSetData($Label1, "Error: Connection lost..") Return EndIf $m = _StringBetween(FileRead($FileName1), "<prx:proxy><prx:ip>", "</prx:check_timestamp></prx:proxy>") _GUICtrlListView_BeginUpdate($ListView1) ; <<<<<<<<<<<<<<<<<< makes updating the ListView faster GUISetState(@SW_HIDE, $Form1) ; <<<<<<<<<<<<<<<<<<< Hide the main GUI while updating Local $ProgressGUI = _ProgressGUI("Processing, please wait", 1) For $i = 1 To UBound($m) - 1 Local $rep $rep = StringReplace($m[$i], "</prx:ip><prx:port>", "_") $rep = StringReplace($rep, "</prx:port><prx:type>", "_") $rep = StringReplace($rep, "</prx:type><prx:country>", "_") $rep = StringReplace($rep, "</prx:country><prx:check_timestamp>", "_") $FIN = StringSplit($rep, "_") If $FIN[3] = "Transparent" Then Sleep(1) $COUNT = $COUNT + 1 GUICtrlSetData($Label1, "Proxies N° " & $COUNT) GUICtrlSetData($ProgressGUI[2], "Processing, please wait" & @CRLF & "Proxies N° " & $COUNT) $Lister[$COUNT][1] = GUICtrlCreateListViewItem($FIN[1] & ":" & $FIN[2] & "|" & $FIN[3] & "|" & $FIN[4] & "|" & $FIN[5], $ListView1) EndIf ;~ GUICtrlSetData($ProgressGUI[1], ($i / (UBound($m) - 1)) * 100) ; <<<<<<<<< Progress bar fills up GUICtrlSetData($ProgressGUI[1], 100 - ($i / (UBound($m) - 1)) * 100) ; <<<<<<<<<< Progress bar moves down Next _GUICtrlListView_EndUpdate($ListView1) ; <<<<<<<<<<<<<< added GUIDelete($ProgressGUI[0]) ; <<<<<<<<<<<< deletes the Progress bar GUI GUISetState(@SW_SHOW, $Form1) ; <<<<<<<<<<< Shows your original GUI when it's all done. EndFunc ;==>GETPROXY Func SELECTED() If GUICtrlRead($Checkbox3) = 1 Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride", "REG_SZ", "<local>") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) Else RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) EndIf If GUICtrlRead($Tab1) Then Call("favo") Return EndIf If GUICtrlRead($Checkbox1) = 1 Then If GUICtrlRead($Checkbox2) = 1 Then GUICtrlSetData($Label2, "") $Random = Random(1, $COUNT, 1) $selected = GUICtrlRead($Lister[$Random][1]) If Not $selected <> "" Then Return GUICtrlSetBkColor($Lister[$Random][1], 0xCCFFCC) GUICtrlSendMsg($ListView1, 0x1013, $Random - 1, 1) Else $selected = GUICtrlRead(GUICtrlRead($ListView1)) If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then GUICtrlSetData($Label2, "") Return ElseIf Not $selected <> "" Then GUICtrlSetData($Label2, "Please select proxy first.") Return EndIf EndIf $StringSplit = StringSplit($selected, "|", 1) $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1) $ping = Ping($IP, 9999) GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1]) DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) Else RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) GUICtrlSetData($Label2, " Your current proxy is Default !") EndIf EndFunc ;==>SELECTED ; #FUNCTION# ==================================================================================================================== ; Name...........: _ProgressGui ; Description ...: A small splash screen type GUI with a progress bar and a configurable label ; Syntax.........: _ProgressGUI($MsgText = "Text Message"[, $_MarqueeType = 0[, $_iFontsize = 14[, $_sFont = "Arial"[, $_iXSize = 290[, $_iYSize = 100[, $_GUIColor = 0x00080FF[, $_FontColor = 0x0FFFC19]]]]]]]) ; Parameters ....: $MsgText - Text to display on the GUI ; $_MarqueeType - [optional] Style of Progress Bar you want to use: ; |0 - Marquee style [default] ; |1 - Normal Progress Bar style ; $_iFontsize - [optional] The font size that you want to display the $MsgText at [default = 14] ; $_sFont - [optional] The font you want the message to use [default = "Arial"] ; $_iXSize - [optional] Width of the GUI [Default = 290] - Minimum size is 80 ; $_iYSize - [optional] Height of the GUI [Default = 100] ; $_GUIColor - [optional] Background color of the GUI [default = 0x00080FF = Blue] ; $_sFontColor - [optional] Color of the text message [default = 0x0FFFC19 = Yellow] ; Return values .: Success - Returns an array of the Control IDs created in the format: ; |array[0] = The handle of the GUI ; |array[1] = The handle of the Progress bar ; |array[2] = The handle of the label ; Failure - 0 and @error to 1 if the GUI couldn't be created ; Author ........: Bob Marotte (BrewManNH) ; Modified.......: ; Remarks .......: This will create a customizable GUI with a progress bar. The default style of the progress bar ; using this function is the Marquee style of progress bar. If you call this function with any ; positive, non-zero number it will use the normal progress bar style. All optional parameters ; will accept the Default keyword, an empty string "", or -1 if passed to the function, except ; the color parameters which will not accept the Default keyword. ; Use the array[0] return value to delete the GUI when you're done using it (ex. GUIDelete($Returnvalue[0]) ; Related .......: None ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ProgressGUI($MsgText = "Text Message", $_MarqueeType = 0, $_iFontsize = 14, $_sFont = "Arial", $_iXSize = 290, $_iYSize = 100, $_GUIColor = 0x00080FF, $_FontColor = 0x0FFFC19) Local $PBMarquee[3] ; bounds checking/correcting If $_iFontsize = "" Or $_iFontsize = "Default" Or $_iFontsize = "-1" Then $_iFontsize = 14 If $_iFontsize < 1 Then $_iFontsize = 1 If $_iXSize = "" Or $_iXSize = "-1" Or $_iXSize = Default Then $_iXSize = 290 If $_iXSize < 80 Then $_iXSize = 80 If $_iXSize > @DesktopWidth - 50 Then $_iXSize = @DesktopWidth - 50 If $_iYSize = "" Or $_iYSize = "-1" Or $_iYSize = Default Then $_iYSize = 100 If $_iYSize > @DesktopHeight - 50 Then $_iYSize = @DesktopHeight - 50 If $_GUIColor = "" Or $_GUIColor = "-1" Then $_GUIColor = 0x00080FF If $_sFont = "" Or $_sFont = "-1" Or $_sFont = "Default" Then $_sFont = "Arial" ;create the GUI $PBMarquee[0] = GUICreate("", $_iXSize, $_iYSize, -1, -1, BitOR(0x00400000, 0x80000000)) If @error Then Return SetError(@error, 0, 0) ; if there's any error with creating the GUI, return the error code GUISetBkColor($_GUIColor, $PBMarquee[0]) ; Create the progressbar If $_MarqueeType < 1 Then ; if $_MarqueeType < 1 then use the Marquee style progress bar $PBMarquee[1] = GUICtrlCreateProgress(20, $_iYSize - 20, $_iXSize - 40, 15, 9) ; uses the $PBS_SMOOTH and $PBS_MARQUEE style GUICtrlSendMsg($PBMarquee[1], 1034, True, 20) Else ; If $_MarqueeType > 0 then use the normal style progress bar $PBMarquee[1] = GUICtrlCreateProgress(20, $_iYSize - 20, $_iXSize - 40, 15, 1) ; Use the $PBS_SMOOTH style EndIf $PBMarquee[2] = GUICtrlCreateLabel($MsgText, 20, 20, $_iXSize - 40, $_iYSize - 45) ; create the label for the GUI GUICtrlSetFont(-1, $_iFontsize, 400, Default, $_sFont) GUICtrlSetColor(-1, $_FontColor) GUISetState() Return SetError(0, 0, $PBMarquee) ;Return the ControlIDs of the GUI and the Progress bar EndFunc ;==>_ProgressGUI
    1 point
  3. What is the problem with your script? If you expect anyone to help you, you have to help us first by explaining what the issue is. I'm not going to run this script just to find out what that is, and looking through it line by line isn't going to do much without some idea of what to look for.
    1 point
  4. BlackHoleSun, Add a @TAB in the definition title: #include <GUIConstantsEx.au3> HotKeySet("^t", "_Test") $hGUI = GUICreate("Test", 500, 500) $mFileMenu = GUICtrlCreateMenu("File") $mTestItem = GUICtrlCreateMenuItem("Test" & @TAB & "Ctrl-T", $mFileMenu) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateMenuItem("", $mFileMenu) $mExitItem = GUICtrlCreateMenuItem("Exit", $mFileMenu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $mExitItem Exit Case $mTestItem _Test() EndSwitch WEnd Func _Test() MsgBox(0, "Hi", "Working!") EndFuncAll clear? M23
    1 point
  5. If you have to use #RequireAdmin, then you have to remap the drives that the files are located on afterwards. Otherwise, the script can't find the files. Use DriveMapAdd to remap the drive, you probably don't want the drive mapping to be presistent though so make sure you set that to no.
    1 point
  6. JLogan3o13

    SCCM 2007 Front End

    Hi, trwatters. Funny you should ask The customer I wrote this for just came to me with almost the exact same list of requirements as part of a Windows7 migration (6500 machines, yay me). I am working on this as we speak, and hope to have a BETA sometime before April. I will definitely post back here once I have it ready.
    1 point
  7. This: $Password= InputBox("Verification","Put your Password in here") $apass=GUICtrlRead($Password) $realpw=IniReadSection("password.ini","Password") If Guictrlread($Password)= $realpw Then Is written wrong, InputBox returns the string entered into it. You can't then use GUICtrlRead on the return from it because it's not a control ID returned. To use that you'd need to check the $realpw variable against the string returned, not try to read from a non-existent control. If $Password = $realpw Then Even better would be to create a hash of the password and put that into the ini instead of the plaintext password. Search the forum for what that means. INI files have zero security for password storage because they're plaintext.
    1 point
  8. This might worked, it's untested, but should do what you're looking for. Case $Menue_Load_1 ;=>> Load from INI $aPortal = IniReadSection($IniName, "Portal") $ausername = IniReadSection($IniName, "Username") $apassword = IniReadSection($IniName, "Password") For $I = 1 To $aPortal[0][0] GUICtrlCreateListViewItem($aPortal[$I][1] & "|" & $ausername[$I][1] & "|" & $ausername[$I][1], $hListview) Next You'd probably have to add a _GUICtrlListView_DeleteAllItems before adding anything to the listview otherwise you'll get duplicate entries.
    1 point
  9. Look at IniReadSection, that will allow you to know how many items are in each section, then you can loop through them to add them back into the LV with GUICtrlCreateListViewItem, basically do in reverse what I did to put them in there.
    1 point
  10. You're not saving the contents of the ListView to the INI file, you're saving the same information just in different keys because you're using the variables holding the return from the input boxes. All you're ever going to get is the last value they hold. Changing this section of your code might do what you want. Case $Menue_Save_1 ;=>> Save 2 INI $count_of_items = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $count_of_items - 1 Step +1 IniWrite($IniName, "Portal", $i, _GUICtrlListView_GetItemText($hListView, $i, 0)) IniWrite($IniName, "Username", $i, _GUICtrlListView_GetItemText($hListView, $i, 1)) IniWrite($IniName, "Password", $i, _GUICtrlListView_GetItemText($hListView, $i, 2)) Next
    1 point
  11. This one seems to be working properly: AVIWriter Extented Example.au3 #include "AVIWriter Extented.au3" #include <Misc.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $sFile = @ScriptDir & "\test.avi" FileDelete($sFile) Global $rec_duration = 5 ;5 seconds Global $fps = 5 Global Const $dll = DllOpen("user32.dll") Global $hGUI_Grab2AVI = GUICreate("", 0, 0, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW, WinGetHandle(AutoItWinGetTitle())) GUISetBkColor(0xFF0000, $hGUI_Grab2AVI) GUISetState(@SW_SHOW, $hGUI_Grab2AVI) Global $aMPos, $hWin, $hWinAncestor, $hWnd, $aRet_prev, $aPos Global Const $frame_size = 3 Global $tPoint = DllStructCreate($tagPOINT) Global $esc = True Global $mxo, $myo While Not _IsPressed("1B", $dll) * Sleep(30) $aMPos = MouseGetPos() DllStructSetData($tPoint, 1, $aMPos[0]) DllStructSetData($tPoint, 2, $aMPos[1]) $hWin = _WinAPI_WindowFromPoint($tPoint) $hWinAncestor = _WinAPI_GetAncestor($hWin, 2) $hWnd = HWnd($hWinAncestor) $aRet_prev = -1 $aPos = WinGetPos($hWnd) If $hWnd <> $hGUI_Grab2AVI And $hWnd <> $aRet_prev Then $aRet_prev = $hWnd If $aMPos[0] <> $mxo Or $aMPos[1] <> $myo Then WinMove($hGUI_Grab2AVI, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3], 1) _GuiHole($hGUI_Grab2AVI, $frame_size, $frame_size, $aPos[2] - 2 * $frame_size, $aPos[3] - 2 * $frame_size, $aPos[2], $aPos[3]) WinSetOnTop($hGUI_Grab2AVI, 0, 1) ToolTip("Press CTRL to start capturing of" & @LF & "marked window to a AVI file!" & @LF & @LF & _ "Duration: " & $rec_duration & " seconds @ " & $fps & " fps" & @LF & _ "Windows Size: " & $aPos[2] & " x " & $aPos[3], $aMPos[0] + 20, $aMPos[1] + 20) $mxo = $aMPos[0] $myo = $aMPos[1] EndIf EndIf If _IsPressed("11", $dll) Then $esc = False ExitLoop EndIf WEnd ToolTip("") GUIDelete($hGUI_Grab2AVI) If $esc Then Exit MsgBox(0, "Information", "Aborted", 10) _StartAviLibrary() Global $aAVI = _CreateAvi($sFile, $fps, $aPos[2], $aPos[3]) If @error Then close() Global $hBmp Global $fSleep = 1000 / $fps, $t, $td Global $total_FPS = $rec_duration * $fps, $fps_c = 1 $k32_dll = DllOpen("kernel32.dll") Do $fTimer = TimerInit() $hBmp = _ScreenCapture_CaptureWnd("", $hWnd) _AddHBitmapToAvi($aAVI, $hBmp) _WinAPI_DeleteObject($hBmp) $fps_c += 1 $td = $fSleep - TimerDiff($fTimer) If $td > 0 Then DllCall($k32_dll, "none", "Sleep", "dword", $td) EndIf If $fps_c > $total_FPS Then Close() EndIf Until False Func Close() DllClose($dll) _GDIPlus_Shutdown() _CloseAvi($aAVI) _StopAviLibrary() ConsoleWrite("AVI filesize: " & Round(FileGetSize($sFile) / 1024 ^ 2, 2) & " MB" & @CRLF) Exit MsgBox(0, "Information", "Done!", 15) EndFunc ;==>close Func _GuiHole($hWnd, $i_x, $i_y, $i_sizew, $i_sizeh, $width, $height) Local $outer_rgn, $inner_rgn, $combined_rgn $outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height) $inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh) $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($outer_rgn) _WinAPI_DeleteObject($inner_rgn) _WinAPI_SetWindowRgn($hWnd, $combined_rgn) EndFunc ;==>_GuiHole AVIWriter Extented.au3 #include-once #include <WinAPI.au3> #region AVIWriter UDF Global Const $OF_CREATE = 0x00001000 Global Const $AVIIF_KEYFRAME = 0x00000010 Global Const $ICMF_CHOOSE_KEYFRAME = 1, $ICMF_CHOOSE_DATARATE = 2 Global Const $AVIERR_UNSUPPORTED = 0x80044065 Global Const $AVIERR_BADPARAM = 0x80044066 Global Const $AVIERR_MEMORY = 0x80044067 Global Const $AVIERR_NOCOMPRESSOR = 0x80044071 Global Const $AVIERR_CANTCOMPRESS = 0x80044075 Global Const $AVIERR_ERROR = 0x800440C7 Global Const $AVIERR_OK = 0 Global $Avi32_Dll Global Const $ICINFO = _ "DWORD dwSize;DWORD fccType;DWORD fccHandler;DWORD dwFlags;DWORD dwVersion;DWORD dwVersionICM;" & _ "WCHAR szName[16];WCHAR szDescription[128];WCHAR szDriver[128];" ;http://msdn.microsoft.com/en-us/library/dd183374(v=vs.85).aspx Global Const $BITMAPFILEHEADER = "WORD bfType;DWORD bfSize;WORD bfReserved1;WORD bfReserved2;DWORD bfOffBits;" ;~ Global Const $BITMAPFILEHEADER = "align 2;char magic[2];int size;short res1;short res2;ptr offset;" ;http://msdn.microsoft.com/en-us/library/dd183376(v=vs.85).aspx Global Const $BITMAPINFOHEADER = _ "dword biSize;long biWidth;long biHeight;short biPlanes;short biBitCount;dword biCompression;" & _ "dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;" ;http://msdn.microsoft.com/en-us/library/ms899423.aspx Global Const $AVISTREAMINFO = _ "dword fccType;dword fccHandler;dword dwFlags;dword dwCaps;short wPriority;short wLanguage;dword dwScale;" & _ "dword dwRate;dword dwStart;dword dwLength;dword dwInitialFrames;dword dwSuggestedBufferSize;dword dwQuality;" & _ "dword dwSampleSize;int rleft;int rtop;int rright;int rbottom;dword dwEditCount;dword dwFormatChangeCount;wchar[64];" ;http://msdn.microsoft.com/en-us/library/dd756791(v=VS.85).aspx Global Const $AVICOMPRESSOPTIONS = _ "DWORD fccType;DWORD fccHandler;DWORD dwKeyFrameEvery;DWORD dwQuality;DWORD dwBytesPerSecond;" & _ "DWORD dwFlags;PTR lpFormat;DWORD cbFormat;PTR lpParms;DWORD cbParms;DWORD dwInterleaveEvery;" ;http://www.fourcc.org/codecs.php Func _Create_mmioFOURCC($FOURCC) ;coded by UEZ If StringLen($FOURCC) <> 4 Then Return SetError(1, 0, 0) Local $aFOURCC = StringSplit($FOURCC, "", 2) Return BitOR(Asc($aFOURCC[0]), BitShift(Asc($aFOURCC[1]), -8), BitShift(Asc($aFOURCC[2]), -16), BitShift(Asc($aFOURCC[3]), -24)) EndFunc ;==>_Create_mmioFOURCC Func _DecodeFOURCC($iFOURCC);coded by UEZ If Not IsInt($iFOURCC) Then Return SetError(1, 0, 0) Return Chr(BitAND($iFOURCC, 0xFF)) & Chr(BitShift(BitAND(0x0000FF00, $iFOURCC), 8)) & Chr(BitShift(BitAND(0x00FF0000, $iFOURCC), 16)) & Chr(BitShift($iFOURCC, 24)) EndFunc ;==>_DecodeFOURCC ;monoceres, Prog@ndy, UEZ Func _CreateAvi($sFilename, $FrameRate, $Width, $Height, $BitCount = 24, $mmioFOURCC = "MSVC", $iKeyFrameEvery = 10) Local $RetArr[6] ;avi file handle, compressed stream handle, bitmap count, BitmapInfoheader, Stride, stream handle Local $aRet, $pFile, $tASI, $tACO, $pStream, $psCompressed Local $stride = BitAND(($Width * ($BitCount / 8) + 3), BitNOT(3)) Local $tBI = DllStructCreate($BITMAPINFOHEADER) DllStructSetData($tBI, "biSize", DllStructGetSize($tBI)) DllStructSetData($tBI, "biWidth", $Width) DllStructSetData($tBI, "biHeight", $Height) DllStructSetData($tBI, "biPlanes", 1) DllStructSetData($tBI, "biBitCount", $BitCount) DllStructSetData($tBI, "biSizeImage", $stride * $Height) $tASI = DllStructCreate($AVISTREAMINFO) DllStructSetData($tASI, "fccType", _Create_mmioFOURCC("vids")) DllStructSetData($tASI, "fccHandler", _Create_mmioFOURCC($mmioFOURCC)) DllStructSetData($tASI, "dwScale", 1) DllStructSetData($tASI, "dwRate", $FrameRate) DllStructSetData($tASI, "dwQuality", -1) ;Quality is represented as a number between 0 and 10,000. For compressed data, this typically represents the value of the quality parameter passed to the compression software. If set to &#8211;1, drivers use the default quality value. DllStructSetData($tASI, "dwSuggestedBufferSize", $stride * $Height) DllStructSetData($tASI, "rright", $Width) DllStructSetData($tASI, "rbottom", $Height) ;~ $tParms = DllStructCreate($ICINFO) ;~ DllCall("Msvfw32.dll", "BOOL", "ICInfo", "DWORD", _Create_mmioFOURCC("vidc"), "DWORD", _Create_mmioFOURCC($mmioFOURCC), "ptr", DllStructGetPtr($tParms)) ;~ $tACO = DllStructCreate($AVICOMPRESSOPTIONS) ;~ DllStructSetData($tACO, "fccType", _Create_mmioFOURCC("vids")) ;~ DllStructSetData($tACO, "fccHandler", _Create_mmioFOURCC($mmioFOURCC)) ;~ DllStructSetData($tACO, "dwKeyFrameEvery", 10) ;~ DllStructSetData($tACO, "dwQuality", 10000) ;~ DllStructSetData($tACO, "dwBytesPerSecond", 0) ;~ DllStructSetData($tACO, "dwFlags", 8) ;~ DllStructSetData($tACO, "lpFormat", 0) ;~ DllStructSetData($tACO, "cbFormat", 0) ;~ DllStructSetData($tACO, "lpParms", DllStructGetPtr($tParms)) ;~ DllStructSetData($tACO, "cbParms", DllStructGetSize($tParms)) ;~ DllStructSetData($tACO, "dwInterleaveEvery", 0) $tACO = DllStructCreate($AVICOMPRESSOPTIONS) ;~ DllStructSetData($tACO, "fccType", _Create_mmioFOURCC("vids")) ;~ DllStructSetData($tACO, "fccHandler", _Create_mmioFOURCC($mmioFOURCC)) ;~ DllStructSetData($tACO, "dwKeyFrameEvery", $iKeyFrameEvery) $aRet = DllCall($Avi32_Dll, "int", "AVIFileOpenW", "ptr*", 0, "wstr", $sFilename, "uint", $OF_CREATE, "ptr", 0) $pFile = $aRet[1] $aRet = DllCall($Avi32_Dll, "int", "AVIFileCreateStream", "ptr", $pFile, "ptr*", 0, "ptr", DllStructGetPtr($tASI)) $pStream = $aRet[2] $aRet = DllCall($Avi32_Dll, "int_ptr", "AVISaveOptions", "hwnd", 0, "uint", BitOR($ICMF_CHOOSE_DATARATE, $ICMF_CHOOSE_KEYFRAME), "int", 1, "ptr*", $pStream, "ptr*", DllStructGetPtr($tACO)) If $aRet[0] <> 1 Then $RetArr[0] = $pFile $RetArr[1] = $pStream $RetArr[2] = 0 $RetArr[3] = $tBI $RetArr[4] = $Stride $RetArr[5] = $pStream Return SetError(1, 0, $RetArr) EndIf ;http://msdn.microsoft.com/en-us/library/dd756811(v=VS.85).aspx $aRet = DllCall($Avi32_Dll, "int", "AVIMakeCompressedStream", "ptr*", 0, "ptr", $pStream, "ptr", DllStructGetPtr($tACO), "ptr", 0) If $aRet[0] <> $AVIERR_OK Then $RetArr[0] = $pFile $RetArr[1] = $pStream $RetArr[2] = 0 $RetArr[3] = $tBI $RetArr[4] = $stride $RetArr[5] = $pStream Return SetError(2, 0, $RetArr) EndIf $psCompressed = $aRet[1] ;The format for the stream is the same as BITMAPINFOHEADER $aRet = DllCall($Avi32_Dll, "int", "AVIStreamSetFormat", "ptr", $psCompressed, "long", 0, "ptr", DllStructGetPtr($tBI), "long", DllStructGetSize($tBI)) $RetArr[0] = $pFile $RetArr[1] = $psCompressed $RetArr[2] = 0 $RetArr[3] = $tBI $RetArr[4] = $stride $RetArr[5] = $pStream ConsoleWrite("$AVISTREAMINFO: " & @CRLF) ConsoleWrite("fccHandler: " & _DecodeFOURCC(DllStructGetData($tASI, "fccHandler")) & @CRLF) ConsoleWrite("fccType: " & DllStructGetData($tASI, "fccType") & @CRLF) ConsoleWrite("dwFlags: " & DllStructGetData($tASI, "dwFlags") & @CRLF) ConsoleWrite("dwCaps: " & DllStructGetData($tASI, "dwCaps") & @CRLF) ConsoleWrite("wPriority: " & DllStructGetData($tASI, "wPriority") & @CRLF) ConsoleWrite("wLanguage: " & DllStructGetData($tASI, "wLanguage") & @CRLF) ConsoleWrite("dwScale: " & DllStructGetData($tASI, "dwScale") & @CRLF) ConsoleWrite("dwStart: " & DllStructGetData($tASI, "dwStart") & @CRLF) ConsoleWrite("dwLength: " & DllStructGetData($tASI, "dwLength") & @CRLF) ConsoleWrite("dwInitialFrames: " & DllStructGetData($tASI, "dwInitialFrames") & @CRLF) ConsoleWrite("dwSuggestedBufferSize: " & DllStructGetData($tASI, "dwSuggestedBufferSize") & @CRLF) ConsoleWrite("dwQuality: " & DllStructGetData($tASI, "dwQuality") & @CRLF) ConsoleWrite("dwRate: " & DllStructGetData($tASI, "dwRate") & @CRLF) ConsoleWrite("dwSampleSize: " & DllStructGetData($tASI, "dwSampleSize") & @CRLF) ConsoleWrite("rleft: " & DllStructGetData($tASI, "rleft") & @CRLF) ConsoleWrite("rtop: " & DllStructGetData($tASI, "rtop") & @CRLF) ConsoleWrite("rright: " & DllStructGetData($tASI, "rright") & @CRLF) ConsoleWrite("rbottom: " & DllStructGetData($tASI, "rbottom") & @CRLF) ConsoleWrite("dwEditCount: " & DllStructGetData($tASI, "dwEditCount") & @CRLF) ConsoleWrite("dwFormatChangeCount: " & DllStructGetData($tASI, "dwFormatChangeCount") & @CRLF & @CRLF) ConsoleWrite("$AVICOMPRESSOPTIONS: " & @CRLF) ConsoleWrite("fccType: " & DllStructGetData($tACO, "fccType") & @CRLF) ConsoleWrite("fccHandler: " & _DecodeFOURCC(DllStructGetData($tACO, "fccHandler")) & @CRLF) ConsoleWrite("dwKeyFrameEvery: " & DllStructGetData($tACO, "dwKeyFrameEvery") & @CRLF) ConsoleWrite("dwQuality: " & DllStructGetData($tACO, "dwQuality") & @CRLF) ConsoleWrite("dwBytesPerSecond: " & DllStructGetData($tACO, "dwBytesPerSecond") & @CRLF) ConsoleWrite("dwFlags: " & DllStructGetData($tACO, "dwFlags") & @CRLF) ConsoleWrite("lpFormat: " & DllStructGetData($tACO, "lpFormat") & @CRLF) ConsoleWrite("cbFormat: " & DllStructGetData($tACO, "cbFormat") & @CRLF) ConsoleWrite("lpParms: " & DllStructGetData($tACO, "lpParms") & @CRLF) ConsoleWrite("cbParms: " & DllStructGetData($tACO, "cbParms") & @CRLF) ConsoleWrite("dwInterleaveEvery: " & DllStructGetData($tACO, "dwInterleaveEvery") & @CRLF & @CRLF) ConsoleWrite("$ICINFO: " & @CRLF) ConsoleWrite("dwSize: " & DllStructGetData($ICINFO, "dwSize") & @CRLF) ConsoleWrite("fccType: " & DllStructGetData($ICINFO, "fccType") & @CRLF) ConsoleWrite("fccHandler: " & DllStructGetData($ICINFO, "fccHandler") & @CRLF) ConsoleWrite("dwFlags: " & DllStructGetData($ICINFO, "dwFlags") & @CRLF) ConsoleWrite("dwVersion: " & DllStructGetData($ICINFO, "dwVersion") & @CRLF) ConsoleWrite("dwVersionICM: " & DllStructGetData($ICINFO, "dwVersionICM") & @CRLF) ConsoleWrite("szName: " & DllStructGetData($ICINFO, "szName") & @CRLF) ConsoleWrite("szDescription: " & DllStructGetData($ICINFO, "szDescription") & @CRLF) ConsoleWrite("szDriver: " & DllStructGetData($ICINFO, "szDriver") & @CRLF & @CRLF) Return $RetArr EndFunc ;==>_CreateAvi ;Adds a bitmap file to an already opened avi file. ;monoceres, Prog@ndy Func _AddHBitmapToAvi(ByRef $Avi_Handle, $hBitmap) Local $DC = _WinAPI_GetDC(0) Local $hDC = _WinAPI_CreateCompatibleDC($DC) _WinAPI_ReleaseDC(0, $DC) Local $OldBMP = _WinAPI_SelectObject($hDC, $hBitmap) Local $bits = DllStructCreate("byte[" & DllStructGetData($Avi_Handle[3], "biSizeImage") & "]") _WinAPI_GetDIBits($hDC, $hBitmap, 0, Abs(DllStructGetData($Avi_Handle[3], "biHeight")), DllStructGetPtr($bits), DllStructGetPtr($Avi_Handle[3]), 0) _WinAPI_SelectObject($hDC, $OldBMP) _WinAPI_DeleteDC($hDC) DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bits), _ "long", DllStructGetSize($bits), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0) $Avi_Handle[2] += 1 EndFunc ;==>_AddHBitmapToAvi ;Adds a bitmap file to an already opened avi file. Func _AddBitmapToAvi(ByRef $Avi_Handle, $sBitmap) Local $bm = LoadBitmap($sBitmap, True) DllCall($Avi32_Dll, "int", "AVIStreamWrite", "ptr", $Avi_Handle[1], "long", $Avi_Handle[2], "long", 1, "ptr", DllStructGetPtr($bm[2]), _ "long", DllStructGetSize($bm[2]), "long", $AVIIF_KEYFRAME, "ptr*", 0, "ptr*", 0) $Avi_Handle[2] += 1 EndFunc ;==>_AddBitmapToAvi ;Returns array with 3 elements ;[0]=BITMAPFILEHEADER ;[1]=BITMAPINFOHEADER ;[2]=Bitmap data buffer (if specified) Func LoadBitmap($sFilename, $LoadData = False) Local $RetArr[3] Local $byref Local $tBIH, $tBFH, $buffer, $fhandle $tBFH = DllStructCreate($BITMAPFILEHEADER) $tBIH = DllStructCreate($BITMAPINFOHEADER) $fhandle = _WinAPI_CreateFile($sFilename, 2, 2, 0, 0) _WinAPI_ReadFile($fhandle, DllStructGetPtr($tBFH), DllStructGetSize($tBFH), $byref) _WinAPI_ReadFile($fhandle, DllStructGetPtr($tBIH), DllStructGetSize($tBIH), $byref) $RetArr[0] = $tBFH $RetArr[1] = $tBIH If Not $LoadData Then _WinAPI_CloseHandle($fhandle) Return $RetArr EndIf $buffer = DllStructCreate("byte[" & DllStructGetData($tBFH, "size") - 54 & "]") $RetArr[2] = $buffer _WinAPI_ReadFile($fhandle, DllStructGetPtr($buffer), DllStructGetSize($buffer), $byref) _WinAPI_CloseHandle($fhandle) Return $RetArr EndFunc ;==>LoadBitmap ;Init the avi library Func _StartAviLibrary() $Avi32_Dll = DllOpen("Avifil32.dll") DllCall($Avi32_Dll, "none", "AVIFileInit") EndFunc ;==>_StartAviLibrary ;Release the library Func _StopAviLibrary() DllCall($Avi32_Dll, "none", "AVIFileExit") DllClose($Avi32_Dll) EndFunc ;==>_StopAviLibrary Func _CloseAvi($Avi_Handle) DllCall($Avi32_Dll, "int", "AVIStreamRelease", "ptr", $Avi_Handle[1]) DllCall($Avi32_Dll, "int", "AVIStreamRelease", "ptr", $Avi_Handle[5]) DllCall($Avi32_Dll, "int", "AVIFileRelease", "ptr", $Avi_Handle[0]) EndFunc ;==>_CloseAvi #endregion AVIWriter UDF Or look here: Thanks to trancexx for pointing me to the right direction! Br, UEZ Edit: fixed issues from below. Edit2: updated UDF and example code
    1 point
×
×
  • Create New...