Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/02/2022 in all areas

  1. https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.1-rc1-setup.zip https://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.16.1-rc1.zip 3.3.16.1 (xxx, 2022) (Release) AutoIt: - Fixed #3866: REGEXPCLASS broken in 3.3.16.0. - Fixed #3875: GUICtrlSetResizing() performance. - Fixed #3865: Image Control resizing behave as forced $GUI_DOCKWIDTH and $GUI_DOCKHEIGHT. - Fixed #3764: StringRegExp() crash with patterns that cause infinite recursion. - Fixed #3876: Hex Number Arithmetic is incorrect. - Fixed #3879: Dim Map to Array. UDFs: - Fixed #3867: Changes in 'SecurityConstants.au3' to avoid name conflict. THIS IS A SCRIPT BREAKING CHANGE - Added: UBound[2] example. - Added: StringRegExp[5] example. - Added: _GUICtrlEdit_SetPadding() function and example. - Fixed: Regression in 3.3.15.1, _WinAPI_RegCreateKey() and _WinAPI_RegOpenkey(). - Added: _WinAPI_RegDeleteKey() can use $hKey as in RegRead(). - Fixed: Regression of #3835 on _GDIPlus_GraphicsGet*(). - Fixed #3871: _ArrayDisplay() Hang sorted array with Null element. - Fixed: _FTP_FileGetSize() very big size. - Fixed #3872: FTP-Server in AutoIt Help no longer accessible. - Fixed #3877: GUICtrlCreateLabel() overlapping controls doc precision ($WS_CLIPSIBLINGS). - Added #3863: _WinAPI_GetCapture(). - Added: Allows _DebugArrayDisplay() to be used in UserFunc. - Added: _ArrayDisplay() and _DebugArrayDisplay() support Min Column width. - Added: _Array2DCreate() support 1D and/or 2D arrays. - Added: _DebugReportVar() display DllStruct content. - Fixed #3883: _DebugArrayDisplay() produces uncalled console message. - Added: _ArrayDisplay() and _DebugArrayDisplay() display {Array[dims]}, {Map[nentry]} and {Object}.
    7 points
  2. Hello guys. I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF. What's UWPOCR? UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API. Features. Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use. Usage: #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc Get Words Rect(Example): More examples here. Check UWPOCR UDF on GitHub. Saludos
    1 point
  3. Advanced from the Simple Script Finder UpDated - Ver 1.0.8 - April 6, 2015 Now - will search and edit/run/etc User Defined file types #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <GuiListBox.au3> ; Ver 1.0.8 April 6, 2015 $SS_SUNKEN = 0x1000 $SS_CENTER = 0x01 FileDelete(@TempDir & "\au3.txt") OnAutoItExitRegister("endscript") Dim $TInfo, $R_[7], $Temp_File, $Temp_Type = StringSplit(".au3,.txt,.ini,.dat,.log,", ",") Dim $Last_loc = "C:\Program Files\AutoIt3\Examples" $AutoItBetaLocation = IniRead(@ScriptDir & "\IE-library.ini", "exe", "dir", "") $Program_2 = $AutoItBetaLocation & "\Autoit3.exe" $maingui = GUICreate("Script/Text Manager v1.0.8", 500, 365) GUISetFont(9, 400, -1, "MS Sans Serif") $vStatus = GUICtrlCreateLabel("View: Search Window", 0, 350, 130, 15, $SS_SUNKEN + $SS_CENTER) GUICtrlCreateLabel("Manager Status:", 130, 350, 120, 15, $SS_SUNKEN + $SS_CENTER) $Status = GUICtrlCreateLabel("System is Ready...", 250, 350, 250, 15, $SS_SUNKEN + $SS_CENTER) GUICtrlSetColor(-1, 0xff0000) GUISetState() $searchgui = GUICreate("Script Finder", 500, 350, 0, 0, $WS_CHILD + $WS_BORDER, "", $maingui) GUISetFont(9, 400, -1, "MS Sans Serif") $location = GUICtrlCreateInput($Last_loc, 20, 20, 340, 20) $C_browse = GUICtrlCreateCheckbox("All Sub-Folders", 380, 20, 100, 20) GUICtrlSetState(-1, $GUI_CHECKED) $browse_btn = GUICtrlCreateButton("Browse Folders", 380, 50, 100, 20) $R_word = GUICtrlCreateRadio("", 20, 50, 20, 20) GUICtrlSetState(-1, $GUI_CHECKED) $word_search = GUICtrlCreateInput("Search word/phrase", 40, 50, 145, 20) $R_title = GUICtrlCreateRadio("", 195, 50, 20, 20) $title_search = GUICtrlCreateInput("Search FileName/Folder", 215, 50, 145, 20) GUICtrlCreateGroup('File Type', 20, 78, 340, 38) $R_[1] = GUICtrlCreateRadio(".au3", 30, 92, 50, 20) GUICtrlSetState(-1, $GUI_CHECKED) $R_[2] = GUICtrlCreateRadio(".txt", 80, 92, 50, 20) $R_[3] = GUICtrlCreateRadio(".ini", 130, 92, 50, 20) $R_[4] = GUICtrlCreateRadio(".dat", 180, 92, 50, 20) $R_[5] = GUICtrlCreateRadio(".log", 230, 92, 50, 20) $R_[6] = GUICtrlCreateRadio("", 280, 92, 15, 20) $R_Input = GUICtrlCreateInput("Type", 298, 90, 50, 20) $go_btn = GUICtrlCreateButton("Start Search", 380, 85, 100, 30) GUICtrlSetState(-1, $GUI_DEFBUTTON) $Edit1 = GUICtrlCreateList("Found File list", 20, 130, 460, 150, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL)) _GUICtrlListBox_SetHorizontalExtent($Edit1, 720) $label = GUICtrlCreateLabel("Files Found with Phrase: None", 140, 290, 220, 20, $SS_SUNKEN + $SS_CENTER) $label2 = GUICtrlCreateLabel("Files Found: None", 20, 290, 100, 20, $SS_SUNKEN + $SS_CENTER) $manage_btn = GUICtrlCreateButton("Manage View", 20, 320, 100, 20) $view_btn = GUICtrlCreateButton("View File", 140, 320, 100, 20) $SciTE_btn = GUICtrlCreateButton("Open in SciTE", 260, 320, 100, 20) $Run_btn = GUICtrlCreateButton("Run File", 380, 290, 100, 20) $Exit_btn = GUICtrlCreateButton("Close", 380, 320, 100, 20) GUISetState() $filesgui = GUICreate("Script Finder", 500, 350, 0, 0, $WS_CHILD + $WS_BORDER, "", $maingui) $Edit2 = GUICtrlCreateList("Searched File list", 20, 20, 460, 270, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL)) _GUICtrlListBox_SetHorizontalExtent($Edit2, 720) $Search_btn = GUICtrlCreateButton("Search View", 20, 320, 100, 20) $copy_btn = GUICtrlCreateButton("Copy File", 140, 320, 100, 20) $rename_btn = GUICtrlCreateButton("Rename File", 260, 320, 100, 20) $Delete_btn = GUICtrlCreateButton("Delete File", 380, 320, 100, 20) $labelA = GUICtrlCreateLabel("Files Found with Phrase: None", 140, 290, 220, 20, $SS_SUNKEN + $SS_CENTER) $label2A = GUICtrlCreateLabel("Files Found: None", 20, 290, 100, 20, $SS_SUNKEN + $SS_CENTER) $Run_btnA = GUICtrlCreateButton("Run File", 380, 290, 100, 20) GUISetState(@SW_HIDE) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit_btn Exit Case $msg = $browse_btn GUICtrlSetData($Status, "Selecting Folder to Search...") $find_loc = FileSelectFolder("Choose a Folder.", "") If $find_loc = "" Then ContinueLoop GUICtrlSetData($location, $find_loc) IniWrite(@ScriptDir & "\IE-library.ini", "search", "dir", $find_loc) Case $msg = $go_btn search_Folders() GUICtrlSetState($word_search, $GUI_FOCUS) Case $msg = $view_btn view() Case $msg = $copy_btn Set_Copy() Case $msg = $rename_btn Set_Rename() Case $msg = $Delete_btn Set_Delete() Case $msg = $Run_btn $TInfo = GUICtrlRead($Edit1) Set_Run($TInfo) Case $msg = $Run_btnA $TInfo = GUICtrlRead($Edit2) Set_Run($TInfo) Case $msg = $SciTE_btn open_SciTE() Case $msg = $manage_btn GUICtrlSetData($vStatus, "View: Manage Window") GUISetState(@SW_HIDE, $searchgui) GUISetState(@SW_SHOW, $filesgui) view_all() Case $msg = $Search_btn GUICtrlSetData($vStatus, "View: Search Window") GUISetState(@SW_HIDE, $filesgui) GUISetState(@SW_SHOW, $searchgui) EndSelect GUICtrlSetData($Status, "System is Ready...") Sleep(20) WEnd Func search_Folders() If Set_File() = -1 Then Return GUICtrlSetData($Status, "Searching for Files...") FileDelete(@TempDir & "\au3.txt") $Found = 0 $Searched = 0 $title = 0 GUICtrlSetData($label, "Files Found with Phrase: " & $Found) GUICtrlSetData($labelA, "Files Found with Phrase: " & $Found) GUICtrlSetData($label2, "Files Found: " & $Searched) GUICtrlSetData($label2A, "Files Found: " & $Searched) GUICtrlSetData($Edit1, "") GUICtrlSetData($Edit2, "") $Temp_Dir = (GUICtrlRead($location)) If $Temp_Dir = "" Then GUICtrlSetData($Status, "No Folder Selected...") MsgBox(262208, "Sorry", "No Folders Selected. ", 2) Return EndIf If StringRight($Temp_Dir, 1) <> "\" Then $Temp_Dir = $Temp_Dir & "\" $Temp_Word = (GUICtrlRead($word_search)) If GUICtrlRead($C_browse) = 1 Then GUICtrlSetData($Status, "Searching in Sub-Folders...PLEASE WAIT") RunWait(@ComSpec & ' /c ' & 'dir "' & $Temp_Dir & $Temp_File & '" /a :h /b /s' & ' > "' & @TempDir & '\au3.txt"', '', @SW_HIDE) Else GUICtrlSetData($Status, "Searching in Local Folder...") $FileList = _FileListToArray($Temp_Dir, $Temp_File, 1) If (Not IsArray($FileList)) Or (@error = 1) Then GUICtrlSetData($Status, "No Files Found...") MsgBox(262208, "Sorry", "No Files Found.", 2) Return EndIf $F_File = FileOpen(@TempDir & "\au3.txt", 2) For $x = 1 To $FileList[0] FileWriteLine($F_File, $Temp_Dir & $FileList[$x]) Next FileClose($F_File) EndIf GUICtrlSetData($Status, "Listing...") If GUICtrlRead($R_title) = 1 Then $Temp_Word = (GUICtrlRead($title_search)) $title = 1 EndIf $hFile = FileOpen(@TempDir & "\au3.txt", 0) While 1 $sLine = FileReadLine($hFile) If @error = -1 Then FileClose($hFile) Return EndIf $Temp_Dir = $sLine If $title = 0 Then $Temp_Search = FileRead($sLine, FileGetSize($sLine)) If $title = 1 Then $Temp_Search = $sLine If StringInStr($Temp_Search, $Temp_Word) Then GUICtrlSetData($Edit1, $sLine, 1) $Found = $Found + 1 GUICtrlSetData($label, "Files Found with Phrase: " & $Found) GUICtrlSetData($labelA, "Files Found with Phrase: " & $Found) EndIf $Searched = $Searched + 1 GUICtrlSetData($label2, "Files Found: " & $Searched) GUICtrlSetData($label2A, "Files Found: " & $Searched) GUICtrlSetData($Status, "Searched:" & $sLine) WEnd FileClose($hFile) EndFunc ;==>search_Folders Func view() GUICtrlSetData($Status, "Viewing in Notepad...") $Temp_Edit = GUICtrlRead($Edit1) $Temp_Word = (GUICtrlRead($word_search)) If $Temp_Edit = "" Or $Temp_Edit = "Found File list" Then GUICtrlSetData($Status, "No File/Folder Selected...") MsgBox(262208, "Sorry", "No Files\Folders Selected. ", 2) Return EndIf Run("notepad.exe " & $Temp_Edit) WinWaitActive("") If GUICtrlRead($R_title) = 1 Then Return GUICtrlSetData($Status, "Searching Notepad...") Sleep(200) Send("!EF") Sleep(200) Send($Temp_Word, 1) Sleep(200) Send("!f") EndFunc ;==>view Func view_all() GUICtrlSetData($Status, "Viewing Manager window...") If Not FileExists(@TempDir & "\au3.txt") Then GUICtrlSetData($Status, "No Searches Were Completed...") MsgBox(262208, "Sorry", "No Files\Folders Searched. ", 2) Return EndIf GUICtrlSetData($Edit2, "") $vFile = FileOpen(@TempDir & "\au3.txt", 0) While 1 $vLine = FileReadLine($vFile) If @error = -1 Then ExitLoop GUICtrlSetData($Edit2, $vLine, 1) GUICtrlSetData($Status, "Setting Files: " & $vLine) WEnd EndFunc ;==>view_all Func Set_Run(ByRef $TInfo) GUICtrlSetData($Status, "Setting up Run Command...") If $TInfo = "" Or $TInfo = "Found File list" Or $TInfo = "Searched File list" Then GUICtrlSetData($Status, "No File Selected to Run...") MsgBox(262208, "Sorry", "No Run File was Selected. ", 2) Return EndIf If GUICtrlRead($R_[6]) = 1 And StringInStr($TInfo, ".au3") = 0 Then GUICtrlSetData($Status, "Running File...") $TInfo = FileGetShortName($TInfo) ShellExecute($TInfo) $TInfo = "" Return EndIf If StringInStr($TInfo, ".au3") = 0 Then GUICtrlSetData($Status, "File Not an Au3 Type...") MsgBox(262208, "Sorry", "Run File was NOT an *au3* Type. " & @CRLF & @CRLF & "Opening File in Notepad ", 2) GUICtrlSetData($Status, "Viewing in Notepad...") Run("notepad.exe " & $TInfo) $TInfo = "" Return EndIf $TInfo = FileGetShortName($TInfo) GUICtrlSetData($Status, "Running File...") RunWait($Program_2 & " " & $TInfo) $TInfo = "" EndFunc ;==>Set_Run Func Set_Copy() GUICtrlSetData($Status, "Setting up Copy...") $CInfo = GUICtrlRead($Edit2) If $CInfo = "" Or $CInfo = "Found File list" Or $CInfo = "Searched File list" Then GUICtrlSetData($Status, "No File Selected to Copy...") MsgBox(262208, "Sorry", "No Copy File was Selected. ", 2) Return EndIf GUICtrlSetData($Status, "Find Destination Folder...") $Linfo = FileSelectFolder("Choose a Destination Folder.", "") If $Linfo = "" Then GUICtrlSetData($Status, "No Folder Selected...") MsgBox(262208, "Sorry", "No Destination Folder was Selected. ", 2) Return EndIf $NInfo = StringSplit($CInfo, "\") $NInfo = $Linfo & "\" & $NInfo[$NInfo[0]] GUICtrlSetData($Status, "Checking if file exists...") If FileExists($NInfo) Then $iMsgBoxAnswer = MsgBox(262212, "Overwrite Existing File?", "The File " & $NInfo & " was found " & @CRLF & @CRLF & "Over-Write File?") If $iMsgBoxAnswer = 7 Then Return EndIf EndIf GUICtrlSetData($Status, "Copying File...") $var1 = FileCopy($CInfo, $NInfo, 1) If $var1 = 1 Then MsgBox(262208, "Success", "The file was Copied ", 2) Else MsgBox(262208, "Fail", "The file was NOT Copied ", 2) EndIf EndFunc ;==>Set_Copy Func Set_Rename() GUICtrlSetData($Status, "Setting Rename File...") $RInfo = GUICtrlRead($Edit2) If $RInfo = "" Or $RInfo = "Found File list" Or $RInfo = "Searched File list" Then GUICtrlSetData($Status, "No File Selected...") MsgBox(262208, "Sorry", "No Rename File was Selected. ", 2) Return EndIf GUICtrlSetData($Status, "Prompt for FileName...") $Minfo = InputBox("Rename File", "Please Type a New FileName. ", "", "", -1, 150) If $Minfo = "" Then GUICtrlSetData($Status, "No Name Given...") MsgBox(262208, "Sorry", "No File Name was Selected. ", 2) Return EndIf $result = StringInStr($RInfo, "\", 0, -1) $NInfo = StringLeft($RInfo, $result) & $Minfo & StringRight($Temp_File, 4) GUICtrlSetData($Status, "Checking if File Exists...") If FileExists($NInfo) Then $iMsgBoxAnswer = MsgBox(262212, "Overwrite Existing File?", "The File " & $NInfo & " was found " & @CRLF & @CRLF & "Over-Write File?") If $iMsgBoxAnswer = 7 Then Return EndIf EndIf GUICtrlSetData($Status, "Renaming File...") $var1 = FileMove($RInfo, $NInfo, 1) If $var1 = 1 Then FileDelete($RInfo) MsgBox(262208, "Success", "The file was Renamed ", 2) Else MsgBox(262208, "Fail", "The file was NOT Renamed ", 2) EndIf $ret = _GUICtrlListBox_FindString($Edit2, $RInfo, 1) If ($ret == $LB_ERR) Then MsgBox(16, "Error #1", "Unknown error from _GUICtrlListBox_FindString") Else $ret2 = _GUICtrlListBox_DeleteString($Edit2, $ret) If ($ret2 == $LB_ERR) Then MsgBox(16, "Error #2", "Unknown error from _GUICtrlListDeleteItem") EndIf EndIf EndFunc ;==>Set_Rename Func Set_Delete() GUICtrlSetData($Status, "Setting up Delete...") $DInfo = GUICtrlRead($Edit2) If $DInfo = "" Or $DInfo = "Found File list" Or $DInfo = "Searched File list" Then GUICtrlSetData($Status, "No File Selected...") MsgBox(262208, "Sorry", "No Delete File was Selected. ", 2) Return EndIf GUICtrlSetData($Status, "Verify that File Exists...") If FileExists($DInfo) Then $iMsgBoxAnswer = MsgBox(262212, "Confirm - Delete File?", "The File " & $DInfo & " was found " & @CRLF & @CRLF & "Delete File?") If $iMsgBoxAnswer = 7 Then Return EndIf EndIf GUICtrlSetData($Status, "Deleting File...") $var1 = FileDelete($DInfo) If $var1 = 1 Then MsgBox(262208, "Success", "The file was Deleted ", 2) Else MsgBox(262208, "Fail", "The file was NOT Deleted ", 2) EndIf $ret = _GUICtrlListBox_FindString($Edit2, $DInfo, 1) If ($ret == $LB_ERR) Then MsgBox(16, "Error #1", "Unknown error from _GUICtrlListBox_FindString") Else $ret2 = _GUICtrlListBox_DeleteString($Edit2, $ret) If ($ret2 == $LB_ERR) Then MsgBox(16, "Error #2", "Unknown error from _GUICtrlListDeleteItem") EndIf EndIf EndFunc ;==>Set_Delete Func Set_File() GUICtrlSetData($Status, "Checking File Type...") For $t = 1 To $Temp_Type[0] If GUICtrlRead($R_[$t]) = 1 Then If $t = $Temp_Type[0] Then $Read_Temp = GUICtrlRead($R_Input) If $Read_Temp = "" Or StringInStr($Read_Temp, ".") = 0 Then GUICtrlSetData($Status, "No File Type Selected...") MsgBox(262208, "Sorry", "No File Type Selected. " & @CRLF & "Example .exe or .dll ", 5) Return -1 EndIf $Temp_File = "*" & $Read_Temp Else $Temp_File = "*" & $Temp_Type[$t] EndIf Return EndIf Next EndFunc ;==>Set_File Func open_SciTE() GUICtrlSetData($Status, "Setting up SciTE...") $Temp_Edit = GUICtrlRead($Edit1) If $Temp_Edit = "" Or $Temp_Edit = "Found File list" Then GUICtrlSetData($Status, "No File Selected for SciTE...") MsgBox(262208, "Sorry", "No Files\Folders Selected. ", 2) Return EndIf GUICtrlSetData($Status, "Checking for Au3 File...") If StringInStr($Temp_Edit, ".au3") = 0 Then $iMsgBoxAnswer = MsgBox(262212, "Verify File Type", "The File " & $Temp_Edit & " is NOT an *au3* Type. " & @CRLF & @CRLF & "Open in SciTE.exe?") If $iMsgBoxAnswer = 7 Then Return EndIf EndIf GUICtrlSetData($Status, "Check if SciTE is Running...") If ProcessExists("SciTE.exe") Then MsgBox(262208, "SciTE is Running", "Placing File in Scite.exe ", 2) GUICtrlSetData($Status, "Running SciTE Now...") $file_name = FileGetShortName($Temp_Edit) $Editor = RegRead("HKCR\AutoIt3Script\Shell\Edit\Command", "") $Splitor = StringSplit($Editor, '"') If FileExists($Splitor[2]) Then Run(StringReplace($Editor, "%1", $file_name)) EndFunc ;==>open_SciTE Func endscript() MsgBox(262208, "Thanks", "... Valuater ", 1) FileDelete(@TempDir & "\au3.txt") EndFunc ;==>endscriptEnjoy!!! 8)
    1 point
  4. Most of these issues related to GDI and GDI+ code is about memory leaks. That's also the case here. There are two memory leaks in the code: neither $CTR_hMyFont[0] nor $CTR_hRgn2[0] are deleted using the DeleteObject() function. Fix these errors and the code will probably run forever. I would write the code this way: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <GUIConstants.au3> Example() Func Example() Local $text = "Next action in " ; Info text to show on screen Local $txtcolor = 0xFF0000 ; Text color Local $printInfo = 1 ; Show info text at all? Local $delay = 0.0 Local $hwnd = GUICreate("Text Region", 800, 200, 10, 10, $WS_POPUP, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor($txtcolor) ; text color GUISetState() While 1 Local $time = TimerInit() do If $printInfo Then CreateTextRgn($hwnd, $text & Round(($delay - TimerDiff($time))/1000) & "s", 100, "Arial", 500) Sleep(100) until TimerDiff($time) >= $delay $delay = Random(52,71,1)*1000 Action() WEnd EndFunc Func CreateTextRgn($CTR_hwnd,$CTR_Text,$CTR_height,$CTR_font="Microsoft Sans Serif",$CTR_weight=1000) Local Const $ANSI_CHARSET = 0, $OUT_CHARACTER_PRECIS = 2, $CLIP_DEFAULT_PRECIS = 0, $PROOF_QUALITY = 2, $FIXED_PITCH = 1, $RGN_XOR = 3 If $CTR_font = "" Then $CTR_font = "Microsoft Sans Serif" If $CTR_weight = -1 Then $CTR_weight = 1000 Local Static $gdi_dll = DLLOpen("gdi32.dll") Local Static $CTR_hDC= DLLCall("user32.dll","int","GetDC","hwnd",$CTR_hwnd) Local Static $CTR_hMyFont = DLLCall($gdi_dll,"hwnd","CreateFont","int",$CTR_height,"int",0,"int",0,"int",0, _ "int",$CTR_weight,"int",0,"int",0,"int",0,"int",$ANSI_CHARSET,"int",$OUT_CHARACTER_PRECIS, _ "int",$CLIP_DEFAULT_PRECIS,"int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$CTR_font ) Local Static $CTR_hOldFont = DLLCall($gdi_dll,"hwnd","SelectObject","int",$CTR_hDC[0],"hwnd",$CTR_hMyFont[0]) DLLCall($gdi_dll,"int","BeginPath","int",$CTR_hDC[0]) DLLCall($gdi_dll,"int","TextOut","int",$CTR_hDC[0],"int",0,"int",0,"str",$CTR_Text,"int",StringLen($CTR_Text)) DLLCall($gdi_dll,"int","EndPath","int",$CTR_hDC[0]) Local $CTR_hRgn1 = DLLCall($gdi_dll,"hwnd","PathToRegion","int",$CTR_hDC[0]) Local $CTR_rc = DLLStructCreate("int;int;int;int") DLLCall($gdi_dll,"int","GetRgnBox","hwnd",$CTR_hRgn1[0],"ptr",DllStructGetPtr($CTR_rc)) Local $CTR_hRgn2 = DLLCall($gdi_dll,"hwnd","CreateRectRgnIndirect","ptr",DllStructGetPtr($CTR_rc)) DLLCall($gdi_dll,"int","CombineRgn","hwnd",$CTR_hRgn2[0],"hwnd",$CTR_hRgn2[0],"hwnd",$CTR_hRgn1[0],"int",$RGN_XOR) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $CTR_hwnd, "long", $CTR_hRgn2[0], "int", 1) ;DLLCall($gdi_dll,"int","DeleteObject","hwnd",$CTR_hMyFont[0]) ; Memory leak <<<<<<<<<<<<<<<<<<<< DLLCall($gdi_dll,"int","DeleteObject","hwnd",$CTR_hRgn1[0]) ;DLLCall("user32.dll","int","ReleaseDC","hwnd",$CTR_hwnd,"int",$CTR_hDC[0]) ;DLLCall($gdi_dll,"int","SelectObject","int",$CTR_hDC[0],"hwnd",$CTR_hOldFont[0]) DLLCall($gdi_dll,"int","DeleteObject","hwnd",$CTR_hRgn2[0]) ; Memory leak <<<<<<<<<<<<<<<<<<<<<<< ;DLLClose($gdi_dll) #forceref $CTR_hOldFont EndFunc Func Action() ; Main program activity goes here EndFunc
    1 point
  5. It is so easy to make mistakes if you need to capture in a loop and analyze it with multiple functions in 1 capture, so I create build-in _Global functions to mainly manage memory to reduce memory leaks. I think _Static is not enough meaning because it already uses the global variable to manage the captured photo and uses it across other _Global functions.
    1 point
×
×
  • Create New...