Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/08/2012 in all areas

  1. trancexx

    Run binary

    It's about running exe from memory as it's often called. So you have some binary data that you want to embed in your script and run afterward like some additional program. In this post I will try to explain how to do it. First to deal with mentioned binary as that's, in spite of the plainness of retrieving it, often insuperable. To avoid questions about that this is one way of getting it: Global $sModule = "E:Program filesGUIDGenGUIDGEN.EXE" ; change to yours wanted Global $hModule = FileOpen($sModule, 16) If @error Then Exit Global $bBinary = FileRead($hModule) FileClose($hModule) Global Const $MAX_LINESIZE = 4095 Global $iNewLine, $j Global $iChinkSize = 32 Global $sBinary For $i = 1 To BinaryLen($bBinary) Step $iChinkSize $j += 1 If 4*($j * $iChinkSize) > $MAX_LINESIZE - 129 Then $iNewLine = 1 EndIf If $iNewLine Then $iNewLine = 0 $j = 0 $sBinary = StringTrimRight($sBinary, 5) $sBinary &= @CRLF & '$bBinary &= "' & StringTrimLeft(BinaryMid($bBinary, $i, $iChinkSize), 2) & '" & _' & @CRLF ContinueLoop EndIf If $i = 1 Then $sBinary &= '$bBinary = "' & BinaryMid($bBinary, $i, $iChinkSize) & '" & _' & @CRLF Else $sBinary &= ' "' & StringTrimLeft(BinaryMid($bBinary, $i, $iChinkSize), 2) & '" & _' & @CRLF EndIf Next $sBinary = StringTrimRight($sBinary, 5) ClipPut($sBinary) ConsoleWrite($sBinary)Now for what's really important... Executable file causes a computer to perform indicated tasks according to encoded instructions. Files that we talk about are in PE format. When exe file is run special loader reads it and performs act of loading. That's how that particular exe gets in touch with a processor. Processor then executes different actions described by the opcodes. Main requirement for any PE file required by the loader is for it to actually exist. To be written on the drive. It can't be in the air. That's not allowed and when you think of it it's only logical. So how to run from memory? I'm gonna fool the system. It will think that all works as it should and will have no idea that it plays my game. There is more than way of doing that. Method described here has been used by different peoples before. When doing research for this post I have encountered many implementations. And I must say that I was very disappointed seeing that even the writers of the code often lack understanding of it. It's kind of pathetic when you see some code used and when asking author what's this or that you get answer "I don't know". And if you ask for the code to be explained by words (any fucking human language) coders fail terribly. How can you write code if you can't explain it?!? Anyway, this is the procedure: Start your script Create new process using CreateProcess function with CREATE_SUSPENDED flag Use GetThreadContext function to fill CONTEXT structure Read and interpret passed binary Allocate enough memory for the new module inside the victim process Simulate loader. Construct the new module (load) in place of allocated space. Make use of mentioned CONTEXT structure. Change entry point data and ImageBaseAddress data. Resume execution If all that went well windows should now be running not the original module but the new, saved in script as a variable. The script: RunBinary.au3 Script is well commented so it shouldn't be too hard to get a grip. New script is taking all possible advantages of PE format. That means if your module (embedded) has relocation directory it will run for sure.If not it could fail. When it will fail? Modules with no reloc directory (IMAGE_DIRECTORY_ENTRY_BASERELOC) ought to be loaded at precise address (stored within module; IMAGE_OPTIONAL_HEADER ImageBase). If for some reason not enough space can be allocated at that address within victim's memory space, function will fail. Thing is system makes rules, if we are not allowed to some memory space of a process there is nothing to do then to try again. So, try again if it fails. Maybe change the 'victim'. edit: 64bit support added. That means you can embed either x64 or x86 modules. If your AutoIt is x64 you embed x64 modules. If AutoIt is x86 embed x86. x64 AutoIt could also use embedded x86 modules but I don't like that because needed structures would have to be changed to something that's not meeting aesthetics standards .
    1 point
  2. AutoIt Windows Screenshooter Key Features: takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Win7+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) drag'n'drop an image to the app for editing To do: capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta). Download source code (10489 downloads previously): AutoIt Windows Screenshooter v1.84 Build 2019-08-18.7z (version 3.3.12.0+ needed!) You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name! Download compiled Exe only: 4shared / Media Fire / Softpedia (1.58mb) Distributing copies of the program in compiled format (exe) must be free of any fee! -----> click here to Donate! (Current donators: 1. Cuong N.) It is designed for Win7+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application! AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!! Main GUI: About Intro: Basic Image Editor: Watermark: Click link for an enhanced version of Watermark Image. Credits: main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys: Main GUI: User your mouse to scroll preview window or Numpad 8: Scroll preview window up Numpad 2: Scroll preview window down Numpad 4: Scroll preview window left Numpad 6: Scroll preview window right Numpad +: zoom in preview window or mouse wheel down Numpad -: zoom out preview window or mouse wheel up F1: capture again on last position F5: refresh Windows Name list PRINTSCREEN: take screenshot from whole screen ALT+PRINTSCR: take a screenshot from active window F10: Undo made changes with Image Editing function F11: take screenshot from whole screen incl mouse cursor F12: take screenshot from whole screen Ctrl+Alt+F9 start "Grab Screen" mode Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)! Ctrl+r: call ruler Ctrl+s: save current displayed image Ctrl+x: exit program ctrl+w: call web grab input field (available only when Aero is enabled) Ctrl+i: call image editor Ctrl+m: call watermark editor Ctrl+z: undo Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)! When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red. ctrl + shift will take the screenshot of appropriate control. To capture GUI menus you can press rmb which simulates the lmb. When a menu is opened press shift additionally to capture it. Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions! Or just mark resize able area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds. When saving the image just enter the extension you wish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF! Image Editor: s: save 😄 copy n: send h: highlighter p: pen r: rectangle e: ellipse a: arrow o: color t: text g: text config Ctrl+z: undo Watermark editor: Ctrl+z: undo To start the app minimized just call it "Windows Screenshooter.exe /min" Maybe it is useful for someone... Any kind of comment is welcome. Br, UEZ Change log:
    1 point
  3. _GUICtrlMenu_Recent() is for those that enjoy using GUICtrlCreateMenu() and would love to have the ability to have a "Recent" menu list with little to no fuss at all. The UDF contains only 7 functions and due to the design of the UDF, reading the recent menu item that was chosen is very easy indeed. Try the Example provided to get an idea of how it works. Any suggestions or improvements then please post below. Thanks. Example: UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: _GUICtrlMenu_Recent_ ; AutoIt Version : v3.3.12.0 or higher ; Language ......: English ; Description ...: Create a recent menu to add previously opened files or other text items to. ; Author(s) .....: guinness ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= Global Const $RECENTMENU_GUID = '051F0003-4E0A-4E4B-8B1A-113B16972254' Global Const $RECENTMENU = 0 Global Const $RECENTMENU_STARTINDEX = 1 Global Enum $RECENTMENU_CAPACITY, $RECENTMENU_ID, $RECENTMENU_INDEX, $RECENTMENU_MENUID, $RECENTMENU_MAX Global Enum $RECENTMENU_CONTROLID, $RECENTMENU_FILEPATH, $RECENTMENU_SHORTPATH ; #CURRENT# ===================================================================================================================== ; _GUICtrlMenu_RecentAdd: Add an item to the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentCapacity: Change the total number of items to be displayed in the recent menu. ; _GUICtrlMenu_RecentCreate: Create a recent menu that is added to an existing menu created by GUICtrlCreateMenu(). ; _GUICtrlMenu_RecentDelete: Delete an item in the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentDestroy: Destroy the handle created by _GUICtrlMenu_RecentCreate(). ; _GUICtrlMenu_RecentIsInMenu: Search if a filepath or text is currently in the menu list. ; _GUICtrlMenu_RecentSelected: Retrieve the text of a selected menu item and delete from the menu list. ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __GUICtrlMenu_RecentDelete ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentAdd ; Description ...: Add an item to the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentAdd(ByRef $aRecentMenu, $sText) ; Parameters ....: $aRecentMenu - $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] ; $sText - Text to be added to the recent menu. ; $bShortText - [optional] Display the text as short text e.g. 'C:\Example...\Test.au3'. Default is False. ; Return values .: Success - ControlID from GUICtrlCreateMenuItem(). ; Failure - 0 and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentAdd(ByRef $aRecentMenu, $sText, $bShortText = False) Local $iError = 1, $iReturn = 0 If __GUICtrlMenu_IsAPI($aRecentMenu) Then _GUICtrlMenu_RecentIsInMenu($aRecentMenu, $sText) __GUICtrlMenu_RecentDelete($aRecentMenu, @extended) If $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then __GUICtrlMenu_RecentDelete($aRecentMenu, $RECENTMENU_STARTINDEX) EndIf Local $sShortText = $sText If IsBool($bShortText) And $bShortText Then $sShortText = StringRegExpReplace($sText, '(^.{3,11}\\|.{11})(.*)(\\.{6,27}|.{27})$', '\1...\3') ; Thanks to AZJIO for the regular expression. EndIf $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] += 1 $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_CONTROLID] = GUICtrlCreateMenuItem($sShortText, $aRecentMenu[$RECENTMENU][$RECENTMENU_MENUID], 0) $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_FILEPATH] = $sText $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_SHORTPATH] = $sShortText $iReturn = $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX]][$RECENTMENU_CONTROLID] $iError = (($iReturn > 0) ? 1 : 0) EndIf Return SetError($iError, 0, $iReturn) EndFunc ;==>_GUICtrlMenu_RecentAdd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentCapacity ; Description ...: Change the total number of items to be displayed in the recent menu. ; Syntax ........: _GUICtrlMenu_RecentCapacity(ByRef $aRecentMenu, $iCapacity) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $iCapacity - Maximum total number of recent menu items to be displayed. If this is exceeded then old values will be overwritten. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentCapacity(ByRef $aRecentMenu, $iCapacity) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then $iCapacity = Int($iCapacity) If $iCapacity >= $RECENTMENU_STARTINDEX And $iCapacity <> $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then $bReturn = True If $iCapacity < $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] Then For $i = $RECENTMENU_STARTINDEX To ($aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] - $iCapacity) GUICtrlDelete($aRecentMenu[$i][$RECENTMENU_CONTROLID]) Next Local $iIndex = ($aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] - $iCapacity) + 1 For $i = $RECENTMENU_STARTINDEX To $iCapacity For $j = 0 To $RECENTMENU_MAX - 1 $aRecentMenu[$i][$j] = $aRecentMenu[$iIndex][$j] Next $iIndex += 1 Next $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = $iCapacity EndIf $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] = $iCapacity ReDim $aRecentMenu[$aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] + $RECENTMENU_STARTINDEX][$RECENTMENU_MAX] EndIf EndIf Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentCapacity ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentCreate ; Description ...: Create a recent menu that is added to an existing menu created by GUICtrlCreateMenu(). ; Syntax ........: _GUICtrlMenu_RecentCreate($iCapacity, $iMenu, $sTitle) ; Parameters ....: $iCapacity - Maximum total number of recent menu items to be displayed. If this is exceeded then old values will be overwritten. ; $iMenu - Existing menu id created by GUICtrlCreateMenu(). ; $sTitle - Title of the recent menu. ; Return values .: Success - Handle to be passed to the recent menu functions. ; Failure - None ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentCreate($iCapacity, $iMenu, $sTitle) If $iCapacity = Default Or Int($iCapacity) <= 0 Then $iCapacity = 10 EndIf Local $aRecentMenu[$iCapacity + $RECENTMENU_STARTINDEX][$RECENTMENU_MAX] $aRecentMenu[$RECENTMENU][$RECENTMENU_ID] = $RECENTMENU_GUID $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] = 0 ; Index of next item. $aRecentMenu[$RECENTMENU][$RECENTMENU_MENUID] = (($iMenu > 0) ? GUICtrlCreateMenu($sTitle, $iMenu) : GUICtrlCreateMenu($sTitle)) $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] = $iCapacity ; Total number of rows. Return $aRecentMenu EndFunc ;==>_GUICtrlMenu_RecentCreate ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentDelete ; Description ...: Delete an item in the recent menu that was created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $vIndex) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $vIndex - Value to be deleted. This can either be an integer of the handle index (see _GUICtrlMenu_RecentIsInMenu() and remarks) ; or a string value of the item. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $vIndex) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then If IsString($vIndex) Then _GUICtrlMenu_RecentIsInMenu($aRecentMenu, $vIndex) $vIndex = @extended EndIf $bReturn = __GUICtrlMenu_RecentDelete($aRecentMenu, $vIndex) EndIf Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentDelete ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentDestroy ; Description ...: Destroy the handle created by _GUICtrlMenu_RecentCreate(). ; Syntax ........: _GUICtrlMenu_RecentDestroy(ByRef $aRecentMenu) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentDestroy(ByRef $aRecentMenu) Local $bReturn = False If __GUICtrlMenu_IsAPI($aRecentMenu) Then $bReturn = True For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] GUICtrlDelete($aRecentMenu[$i][$RECENTMENU_CONTROLID]) Next EndIf $aRecentMenu = 0 Return $bReturn EndFunc ;==>_GUICtrlMenu_RecentDestroy ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentIsInMenu ; Description ...: Search if a filepath or text is currently in the menu list. ; Syntax ........: _GUICtrlMenu_RecentIsInMenu(ByRef $aRecentMenu, $sText) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate(). ; $sText - Text to search for. This is a case-sensitive search. ; Return values .: Success - True and sets @extended to the index position of the text. ; Failure - False and sets @extended to zero. ; Author ........: guinness ; Remarks .......: @extended is set to the index position in the handle. This is useful if using GUICtrlMenu_RecentDelete(). ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentIsInMenu(ByRef $aRecentMenu, $sText) Local $bReturn = False, _ $iExtended = 0 If __GUICtrlMenu_IsAPI($aRecentMenu) Then For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] If ($sText == $aRecentMenu[$i][$RECENTMENU_FILEPATH]) Or ($sText == $aRecentMenu[$i][$RECENTMENU_SHORTPATH]) Then $bReturn = True $iExtended = $i ExitLoop EndIf Next EndIf Return SetExtended($iExtended, $bReturn) EndFunc ;==>_GUICtrlMenu_RecentIsInMenu ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlMenu_RecentSelected ; Description ...: Retrieve the text of a selected menu item and delete from the menu list. ; Syntax ........: _GUICtrlMenu_RecentSelected(ByRef $aRecentMenu, $iMsg) ; Parameters ....: $aRecentMenu - [in/out] Handle created by _GUICtrlMenu_RecentCreate().. ; $iMsg - Message id returned by GUIGetMsg(). ; Return values .: Success - Text of the selected menu. ; Failure - Null and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlMenu_RecentSelected(ByRef $aRecentMenu, $iMsg) Local $iError = 1, _ $sReturn = Null If $iMsg > 0 And __GUICtrlMenu_IsAPI($aRecentMenu) Then For $i = $RECENTMENU_STARTINDEX To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] If $iMsg = $aRecentMenu[$i][$RECENTMENU_CONTROLID] Then $iError = 0 $sReturn = $aRecentMenu[$i][$RECENTMENU_FILEPATH] __GUICtrlMenu_RecentDelete($aRecentMenu, $i) ExitLoop EndIf Next EndIf Return SetError($iError, 0, $sReturn) EndFunc ;==>_GUICtrlMenu_RecentSelected ; #INTERNAL_USE_ONLY#============================================================================================================ Func __GUICtrlMenu_RecentDelete(ByRef $aRecentMenu, $iIndex) Local $bReturn = False If $iIndex >= $RECENTMENU_STARTINDEX And $iIndex <= $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] And GUICtrlDelete($aRecentMenu[$iIndex][$RECENTMENU_CONTROLID]) Then $bReturn = True Local $iSwap = 0 For $i = $iIndex To $aRecentMenu[$RECENTMENU][$RECENTMENU_CAPACITY] - 1 For $j = 0 To $RECENTMENU_MAX - 1 $iSwap = $i + 1 $aRecentMenu[$i][$j] = $aRecentMenu[$iSwap][$j] $aRecentMenu[$iSwap][$j] = Null Next Next $aRecentMenu[$RECENTMENU][$RECENTMENU_INDEX] -= 1 EndIf Return $bReturn EndFunc ;==>__GUICtrlMenu_RecentDelete Func __GUICtrlMenu_IsAPI(ByRef $aRecentMenu) Return UBound($aRecentMenu, $UBOUND_COLUMNS) = $RECENTMENU_MAX And $aRecentMenu[$RECENTMENU][$RECENTMENU_ID] = $RECENTMENU_GUID EndFunc ;==>__GUICtrlMenu_IsAPI Example 1: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include '_GUICtrlMenu_Recent.au3' Example() Func Example() Local $hGUI = GUICreate('_GUICtrlMenu_Recent() Example', 300, 200) Local $iFileMenu = GUICtrlCreateMenu('&File') Local $iOpen = GUICtrlCreateMenuItem('Open', $iFileMenu) GUICtrlSetState($iOpen, $GUI_DEFBUTTON) ; Create a recent menu with a maximum of 5 displayed items. Local $hRecentMenu = _GUICtrlMenu_RecentCreate(5, $iFileMenu, 'Recent Files') GUICtrlCreateMenuItem('', $iFileMenu) ; Seperator Line. GUICtrlCreateMenuItem('Save', $iFileMenu) GUICtrlSetState(-1, $GUI_DISABLE) Local $iExit = GUICtrlCreateMenuItem('Exit', $iFileMenu) Local $iOpenFile = GUICtrlCreateButton('Open File', 5, 10, 85, 25) Local $iIncreaseItems = GUICtrlCreateButton('Increase Recent List', 5, 35, 115, 25) GUISetState(@SW_SHOW, $hGUI) ; Add the current script to the recent menu. _GUICtrlMenu_RecentAdd($hRecentMenu, @ScriptFullPath, True) Local $iMsg = 0, _ $sFilePath = '' While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $iExit ExitLoop Case $iOpenFile, $iOpen $sFilePath = FileOpenDialog('Choose File...', @ScriptDir, 'All (*.*)') If Not @error Then ; Check whether or not the filepath is currently in the recent menu. If it isn't then add to the recent menu. If Not _GUICtrlMenu_RecentIsInMenu($hRecentMenu, $sFilePath) Then ; If the button or open menu items are selected then add a filepath to the recent menu. _GUICtrlMenu_RecentAdd($hRecentMenu, $sFilePath, True) ; Display the text as short text. EndIf EndIf Case $iIncreaseItems ; Increase the capacity to 20 items instead of the previous 5. If _GUICtrlMenu_RecentCapacity($hRecentMenu, 20) Then MsgBox($MB_SYSTEMMODAL, '', 'The recent menu list was increased to a maximum of 20 items.', 0, $hGUI) Else MsgBox($MB_SYSTEMMODAL, '', 'The recent menu list wasn''t increased to a maximum of 20 items. An error occurred.', 0, $hGUI) EndIf Case Else ; Check if the message id returned by GUIGetMsg() is present in the recent menu list. $sFilePath = _GUICtrlMenu_RecentSelected($hRecentMenu, $iMsg) If Not @error Then MsgBox($MB_SYSTEMMODAL, '', 'The recent menu was selected and the following item was chosen' & @CRLF & _ @CRLF & _ $sFilePath, 0, $hGUI) EndIf EndSwitch WEnd ; Destroy the recent menu. _GUICtrlMenu_RecentDestroy($hRecentMenu) GUIDelete($hGUI) EndFunc ;==>Example All of the above has been included in a ZIP file. GUICtrlMenu_Recent.zip
    1 point
  4. Have you ever asked yourself the question(s) What does AutoItWinGetTitle() or AutoItWinSetTitle() do? Is there a simple way to communicate between two AutoIt scripts other than WM_COPYDATA (see in my signature)? How can I store data/text other than saving it to a file? If you have then please read on... I first came across this little trick via KaFu (couple of years ago) who was using it in his example for an alternative of >_Singleton(). I couldn't understand why he was reading the text in an edit box until I decided to delve a little deeper. Turns out the hidden AutoIt window contains an edit box, so with that in mind I decided to post an example of how useful it could be. In this example I add data from the first instance of the program e.g. PID, location, working directory & then grab this data in the second instance. Just to prove I'm not cheating I've also included data of the second instance too so you can see the PID's are totally different. Example 1: Compile this example and run it! Once the hidden window is shown run the executable again. MsgBox's will be displayed during the process explaining what is happening. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Display AutoIt's Hidden Window. See AutoItWinGetTitle and AutoItWinSetTitle for more details. AutoItWinShow() ; Add a text string to AutoIt's Hidden Window. AutoItWinSetText('Welcome to AutoIt V' & @AutoItVersion & @CRLF) ; Add a text string to AutoIt's Hidden Window. AutoItWinSetText('Windows Type: ' & @OSType & @CRLF) ; Display the text stored in AutoIt's Hidden Window. MsgBox($MB_SYSTEMMODAL, '', AutoItWinGetText()) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example ; Retrieve the text in AutoIt's Hidden Window. Func AutoItWinGetText() Local Const $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. Return ControlGetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1')) EndFunc ;==>AutoItWinGetText ; Add text to AutoIt's Hidden Window. Func AutoItWinSetText($sString) Local Const $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. Return ControlSetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1'), AutoItWinGetText() & $sString) EndFunc ;==>AutoItWinSetText ; Display AutoIt's Hidden Window. Returns the handle of the window. Func AutoItWinShow() Local Const $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. WinMove($hWnd, '', (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Move the AutoIt Hidden Window and re-size for a better view of the data that will be set. WinSetState($hWnd, '', @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it. Return $hWnd EndFunc ;==>AutoItWinShowExample 2: Compile this example and run it. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If @Compiled Then Example() Else MsgBox($MB_SYSTEMMODAL, 'AutoIt Hidden Window', 'This example needs to be compiled before you can run it.') ; Show an error if the script isn't compiled. EndIf Func Example() Local Const $sData = 'PID: ' & @AutoItPID & @CRLF & _ ; Create a data string about the running executable. 'Version: ' & @AutoItVersion & @CRLF & _ 'Script Directory: ' & @ScriptDir & @CRLF & _ 'Working Directory: ' & @WorkingDir Local $hAutoIt = WinGetHandle('AutoIt_Hidden_Window') ; Check if the AutoIt Hidden Window exists and if it does then read the details set in the edit box. If IsHWnd($hAutoIt) Then Local Const $sRead = AutoItWinGetText($hAutoIt) ; Retrieve the information of the inital AutoIt Hidden Window. AutoItWinSetText('Now you can close this window.') ; Set the text of the edit box to show it can now be closed. Return MsgBox($MB_SYSTEMMODAL, 'AutoIt Hidden Window', 'Previous PID:-' & @CRLF & _ $sRead & @CRLF & @CRLF & _ 'Current PID:-' & @CRLF & _ $sData & @CRLF & @CRLF & _ 'This will now Exit. Thanks.') EndIf AutoItWinSetTitle('AutoIt_Hidden_Window') ; Set the title of the AutoIt Hidden Window with some custom text, the more unqiue the better. AutoItWinShow() AutoItWinSetText($sData) ; Set the text of the edit box using the data string created at the start of the script. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Just hit the close button to Exit the application. ExitLoop EndSwitch WEnd EndFunc ;==>Example ; Retrieve the text in AutoIt's Hidden Window. Func AutoItWinGetText($hWnd = Default) If IsHWnd($hWnd) = 0 Or $hWnd = Default Then $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. EndIf Return ControlGetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1')) EndFunc ;==>AutoItWinGetText ; Add text to AutoIt's Hidden Window. Func AutoItWinSetText($sString, $hWnd = Default) If IsHWnd($hWnd) = 0 Or $hWnd = Default Then $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. EndIf Return ControlSetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1'), AutoItWinGetText() & $sString) EndFunc ;==>AutoItWinSetText ; Display AutoIt's Hidden Window. Returns the handle of the window. Func AutoItWinShow() Local Const $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window. WinMove($hWnd, '', (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Move the AutoIt Hidden Window and re-size for a better view of the data that will be set. WinSetState($hWnd, '', @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it. Return $hWnd EndFunc ;==>AutoItWinShow Example 3: >Send text to a 2nd instance.
    1 point
  5. Did this one quickly and when I was done I got told Skype already had this, apparently I've completely missed it? anyway, someone might find it useful. #include "include/Skype.au3" $pid = ProcessExists('Spotify.exe') If $pid == 0 Then MsgBox(0, '', 'Spotify has to be running for this to work.') Exit EndIf Global $oldMood = _Skype_ProfileGetMoodText(); Global $currentSong = ''; Global $hwnd = WinGetHandle('[CLASS:SpotifyMainWindow]') While 1 Sleep(1000) $song = StringTrimLeft(WinGetTitle($hwnd), 10) if $song <> $currentSong and $song <> '' Then _Skype_ProfileSetMoodText('(Spotify) ' & $song); EndIf if $song == '' Then _Skype_ProfileSetMoodText($oldMood); EndIf WEnd _Skype_ProfileSetMoodText($oldMood); How to use Have Skype and Spotify running and it'll do the rest. It will change the mood text to the current track in Spotify whenever something is played there. Skype Current Song.rar
    1 point
  6. Thanks here is one with a partial match you can adjust . That can avoid to miss a match for a plurial or a conjugated verb... #Include <Math.au3> $_Result1 = _WordsStringCompare ( 'Hello how are you fine ?', "Are you fine, Hello ?" ) ConsoleWrite ( '+ @extended : ' & @extended & @Crlf ) ConsoleWrite ( '- Equivalence : ' & $_Result1 & '%' & @Crlf ) $_Result2 = _WordsStringCompare ( 'Thanks for the original idea!', 'In my opinion is perfect, ideal even for searches inside files', 1 ) ConsoleWrite ( '+ @extended : ' & @extended & @Crlf ) ConsoleWrite ( '- Equivalence : ' & $_Result2 & '%' & @Crlf ) $_Result3 = _WordsStringCompare ( 'Keep up the good work', 'These tools are very good, glad you have worked on them.', 1, 2 ) ConsoleWrite ( '+ @extended : ' & @extended & @Crlf ) ConsoleWrite ( '- Equivalence : ' & $_Result3 & '%' & @Crlf ) Func _WordsStringCompare ( $_Str1, $_Str2, $_Partial=0, $_StringLenDiffMax=1 ) $_Str1 = StringStripWS ( StringLower ( StringRegExpReplace ( $_Str1, '(?i)[^a-z0-9]', ' ' ) ), 7 ) $_Str2 = StringStripWS ( StringLower ( StringRegExpReplace ( $_Str2, '(?i)[^a-z0-9]', ' ' ) ), 7 ) Local $_Ar1 = StringSplit ( $_Str1, ' ', 2 ), $_Ar2 = StringSplit ( $_Str2, ' ', 2 ), $_Match, $_Slen1, $_Slen2 For $_I = 0 To Ubound ( $_Ar1 ) -1 $_Slen1 = StringLen ( $_Ar1[$_I] ) For $_J = 0 To Ubound ( $_Ar2 ) -1 $_Slen2 = StringLen ( $_Ar2[$_J] ) If $_Ar1[$_I] Then If $_Ar1[$_I] = $_Ar2[$_J] Or _ ( $_Partial And ( StringInStr ( $_Ar2[$_J], $_Ar1[$_I] ) Or StringInStr ( $_Ar1[$_I], $_Ar2[$_J] ) And ( $_Slen1 > 1 And $_Slen2 > 1 ) And ( Abs ( $_Slen1 - $_Slen2 ) <= $_StringLenDiffMax ) ) ) Then ConsoleWrite ( '! $_Ar1[$_I] : ' & $_Ar1[$_I] & ', $_Ar2[$_J] : ' & $_Ar2[$_J] & @Crlf ) $_Ar1[$_I] = '' $_Ar2[$_J] = '' $_Match += 1 EndIf EndIf Next Next Return SetExtended ( $_Match, Round ( $_Match / _Max ( Ubound ( $_Ar1 ), Ubound ( $_Ar2 ) ), 4 ) * 100 ) EndFunc ;==> _WordsStringCompare ( )
    1 point
  7. UEZ

    AVI writing udf

    Well, I will install XViD in my VM and make some tests later when I find some spare time. Here a version which takes the video from 0, 0, 200, 100 with predefinied values. #include <ScreenCapture.au3> ;~ #include <WinAPI.au3>;~~~ #region 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;" #endregion Global $rec_duration = 10 Global $fps = 5 _StartAviLibrary() FileDelete(@ScriptDir & "Test.avi") Global $aAVI = _CreateAvi(@ScriptDir & "Test.avi", $fps, 200, 100) 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("", 0, 0, 0, 200, 100) _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 ExitLoop EndIf Until False _CloseAvi($aAVI) _StopAviLibrary() ConsoleWrite("Done!" & @LF) DllClose($k32_dll) Exit #region AVIWriter UDF ;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 ;~ ConsoleWrite(_DecodeFOURCC(DllStructGetData($tACO, "fccHandler")) & @CRLF) ;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 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 Br, UEZ
    1 point
  8. czardas

    Find Hex String

    That's excellent Firefox, I'm most impressed. I figured it might be a useful question from which other's can learn, including myself! Five Stars!
    1 point
×
×
  • Create New...