Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/20/2021 in all areas

  1. GDI+ can do it faster and with more robustness : #include <GDIPlus.au3> #include <GUIConstants.au3> #include <ScreenCapture.au3> Example() Func Example() _GDIPlus_Startup() Local Const $iW = 300, $iH = 200 ; 3:2 Local Const $iNW = 300, $iNH = 300 ; make it 1:1 Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing part of the screen (3:2) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore Local $hBitmap_Scaled = _GDIPlus_ImageResizeEX($hBitmap, $iNW, $iNH, $iW, $iH) ;resize image with white space below and above Local $hGUI = GUICreate("GDI+ test", $iNW, $iNH) ;create a test gui to display the resized image GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image _GDIPlus_ImageSaveToFile($hBitmap_Scaled, "Test.jpg") ; save it While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() EndFunc ;==>Example Func _GDIPlus_ImageResizeEX($hImage, $iNewWidth, $iNewHeight, $iOldWidth, $iOldHeight) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iNewWidth, $iNewHeight) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) ; fill image with white _GDIPlus_GraphicsFillRect($hBmpCtxt, 0, 0, $iNewWidth, $iNewHeight, $hBrush) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, Int($iNewHeight - $iOldHeight) / 2, $iOldWidth, $iOldHeight) _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BrushDispose($hBrush) Return $hBitmap EndFunc ;==>_GDIPlus_ImageResizeEX
    1 point
  2. Moved to the appropriate forum. Moderation Team
    1 point
  3. OK I have an update. I uninstalled Scite Full, since it was too full for me.. For example, the Tools menu was so long, that you need to hover 2 arrows, to scroll it up and down. And as you guys might've noticed in my other thread, I prefer small and light menus.. So I am back to Scite Lite. (yet much appreciation to you Jos on the work on the Full version) pixelsearch, I implemented what you suggested, and added a pattern for .au3 files. So my SciTEUser.properties file is now: tabsize=4 indent.size=4 indent.size.*.au3=4 use.tabs=1 output.initial.hide=1 output.vertical.size=170 And the problem is solved.. In the Lite edition. BTW, trying to write indent.size.*.*=4 doesn't work. It only accepts a single extension at a time..
    1 point
  4. Hi Zohar, I'm also using Autoit v3.3.14.5, with SciTE-Lite v3.5.4 In case it may be useful to you, here are some parameters from my file SciTEUser.properties The indent size in permanent (4) in any tab and any kind of file. #changed that one permanently (from 3 to 4) on 13 Nov. 2018 indent.size=4 indent.size.*.au3=4 Hope it helps
    1 point
  5. Multi-line treeview itemsMulti-line treeview items are supported through the iIntegral field in the TVITEM structure and custom draw code. The iIntegral value handles multi-line items in the treeview structure. Custom draw code draws the entire item rectangle, the dotted focus rectangle and the individual multi-line texts. Multi-line treeview items are supported by all treeviews and not just semi-virtual or virtual treeviews. To add a multi-line item with 2, 3 or 4 lines, simply set the value of iIntegral to 2, 3 or 4. Both the width and height of a rectangle that can accommodate all the lines must be calculated in the custom draw code. The height is just 2, 3 or 4 times the height of a single-line item. The width must be set to the width of the widest text string in pixels of the 2, 3, or 4 substrings. The width of a text string in pixels is calculated using the GetTextExtentPoint32W() function. The left position of the rectangle is calculated with _GUICtrlTreeView_GetIndent() and the item level. You'll also need to consider that the width of the entire treeview control may not be large enough to accommodate the longest text strings. Data source for multi-line items (Multiline.txt) 0|0 0|1 0|2 1|3 1|This|Line 2 1|is 2|6 2|a 2|very 2|nice|Line 2|Line 3 3|10 3|TreeView 0|, (comma) 1|13 1|indeed. 0|15 Code in a semi-virtual treeview to create and draw multi-line items (1) Multiline Items.au3) ; Create TreeView structure Func CreateTreeView( $aItems ) ; TreeView item information Local $aItem, $iItem ; TreeView level information Local $aLevels[100][2], $iLevel = 0, $iLevelPrev = 0 ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level ; TreeView insert structure Local $tInsert = DllStructCreate( $tagTVINSERTSTRUCT ), $pInsert = DllStructGetPtr( $tInsert ) DllStructSetData( $tInsert, "InsertAfter", $TVI_LAST ) DllStructSetData( $tInsert, "Mask", $TVIF_HANDLE+$TVIF_PARAM+$TVIF_TEXT+$TVIF_INTEGRAL ) DllStructSetData( $tInsert, "Text", -1 ) ; $LPSTR_TEXTCALLBACK ; Add TreeView root $aItem = StringSplit( $aItems[0], "|", 2 ) $iItem = UBound( $aItem ) $aLevels[$iLevel][1] = NULL DllStructSetData( $tInsert, "Param", 0 ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) DllStructSetData( $tInsert, "Integral", $iItem > 2 ? $iItem - 1 : 1 ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) ; Add TreeView items For $i = 1 To UBound( $aItems ) - 1 $aItem = StringSplit( $aItems[$i], "|", 2 ) $iItem = UBound( $aItem ) $iLevel = $aItem[0] If $iLevel <> $iLevelPrev Then $aLevels[$iLevel][1] = $iLevel > $iLevelPrev ? $aLevels[$iLevelPrev][0] _ ; A child of the previous level : GUICtrlSendMsg( $idTreeView, $TVM_GETNEXTITEM, $TVGN_PARENT, $aLevels[$iLevel][0] ) ; A sibling of the level $iLevelPrev = $iLevel EndIf DllStructSetData( $tInsert, "Param", $i ) DllStructSetData( $tInsert, "Parent", $aLevels[$iLevel][1] ) DllStructSetData( $tInsert, "Integral", $iItem > 2 ? $iItem - 1 : 1 ) $aLevels[$iLevel][0] = GUICtrlSendMsg( $idTreeView, $TVM_INSERTITEMW, 0, $pInsert ) Next ; $aLevels[$iLevel][0]/[1] contains the last item/parent of that level EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Switch HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Case $hTreeView Switch DllStructGetData( $tNMHDR, "Code" ) Case $TVN_GETDISPINFOW ; Display TreeView item text Local Static $tBuffer = DllStructCreate( "wchar Text[50]" ), $pBuffer = DllStructGetPtr( $tBuffer ) Local $tDispInfo = DllStructCreate( $tagNMTVDISPINFO, $lParam ), $sText = StringSplit( $aItems[DllStructGetData($tDispInfo,"Param")], "|", 2 )[1] DllStructSetData( $tBuffer, "Text", $sText ) DllStructSetData( $tDispInfo, "Text", $pBuffer ) DllStructSetData( $tDispInfo, "TextMax", 2 * StringLen( $sText ) + 2 ) Case $NM_CUSTOMDRAW Local $tCustomDraw = DllStructCreate( $tagNMTVCUSTOMDRAW, $lParam ) Switch DllStructGetData( $tCustomDraw, "DrawStage" ) ; The current drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent before painting an item Case $CDDS_ITEMPREPAINT ; Before painting an item If UBound( StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ) ) > 2 Then _ Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent after painting an item ; Draw multiline item texts Case $CDDS_ITEMPOSTPAINT ; After painting an item Local Static $iTVIndent = _GUICtrlTreeView_GetIndent( $hTreeView ), $tSize = DllStructCreate( $tagSIZE ), $hBrushHighLight = _WinAPI_GetSysColorBrush( $COLOR_HIGHLIGHT ), $hBrushButtonFace = _WinAPI_GetSysColorBrush( $COLOR_BTNFACE ), $hBrushWhite = _WinAPI_CreateSolidBrush( 0xFFFFFF ) Local $hDC = DllStructGetData( $tCustomDraw, "HDC" ), $tRect = DllStructCreate( $tagRECT, DllStructGetPtr( $tCustomDraw, "Left" ) ), $aItem = StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ), $iItem = UBound( $aItem ), $iMaxTextLen = 0, $iLeft = $iTVIndent * ( $aItem[0] + 1 ) + 3, $iRectWidth = DllStructGetData( $tCustomDraw, "Right" ) - $iLeft, $iTop = DllStructGetData( $tRect, "Top" ), $iItemState = DllStructGetData( $tCustomDraw, "ItemState" ) ; Longest text in pixels of all item texts For $i = 1 To $iItem - 1 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $aItem[$i], "int", StringLen( $aItem[$i] ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 If DllStructGetData( $tSize, "X" ) + 1 > $iMaxTextLen Then $iMaxTextLen = DllStructGetData( $tSize, "X" ) + 1 Next ; Rectangle that includes all item texts If $iMaxTextLen + 4 > $iRectWidth Then _ $iMaxTextLen = $iRectWidth - 4 DllStructSetData( $tRect, "Left", $iLeft ) DllStructSetData( $tRect, "Right", $iLeft + $iMaxTextLen + 4 ) DllStructSetData( $tRect, "Bottom", $iTop + 18 * ( $iItem - 1 ) ) DllCall( "gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $TRANSPARENT ) ; _WinAPI_SetBkMode() Switch BitAND( $iItemState, $CDIS_SELECTED + $CDIS_FOCUS ) Case $CDIS_SELECTED + $CDIS_FOCUS DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushHighLight ) ; _WinAPI_FillRect() DllCall( "user32.dll", "bool", "DrawFocusRect", "handle", $hDC, "struct*", $tRect ) ; _WinAPI_DrawFocusRect() DllCall( "gdi32.dll", "INT", "SetTextColor", "handle", $hDC, "INT", 0xFFFFFF ) ; _WinAPI_SetTextColor() Case $CDIS_SELECTED DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushButtonFace ) ; _WinAPI_FillRect() Case $CDIS_FOCUS Case Else DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushWhite ) ; _WinAPI_FillRect() EndSwitch ; Left start position for item texts DllStructSetData( $tRect, "Left", $iLeft + 2 ) ; Draw all item texts For $i = 1 To UBound( $aItem ) - 1 DllStructSetData( $tRect, "Top", $iTop + 18 * ( $i - 1 ) + 1 ) DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aItem[$i], "int", -1, "struct*", $tRect, "uint", $DT_LEFT+$DT_WORD_ELLIPSIS ) ; _WinAPI_DrawText() Next EndSwitch EndSwitch EndSwitch #forceref $hWnd, $iMsg, $wParam EndFunc Store MaxTextLen in data sourceBecause the width of the longest text string in pixels ($iMaxTextLen) must be calculated each time a multi-line item needs to be redrawn, it can be an advantage to store this width directly in the data source. Multiline-2.txt: 0|000|0 0|000|1 0|000|2 1|000|3 1|000|This|Line 2 1|000|is 2|000|6 2|000|a|A somewhat long new line 2|000|very 2|000|nice|A TreeView item with three lines|Line 3 3|000|10 3|000|TreeView 0|000|, (comma) 1|000|13 1|000|indeed. 0|000|15 2) Store MaxTextLen.au3: ; Cleanup GUIDelete( $hGui ) If $bSaveItems Then _FileWriteFromArray( "Multiline-2.txt", $aItems ) $aItem = StringSplit( $aItems[DllStructGetData($tCustomDraw,"ItemParam")], "|", 2 ) $iMaxTextLen = $aItem[1]+0 ; Longest text in pixels of all item texts If Not $iMaxTextLen Then For $i = 2 To $iItem - 1 DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $aItem[$i], "int", StringLen( $aItem[$i] ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 If DllStructGetData( $tSize, "X" ) + 1 > $iMaxTextLen Then $iMaxTextLen = DllStructGetData( $tSize, "X" ) + 1 Next $bSaveItems = True $iIndex = DllStructGetData( $tCustomDraw, "ItemParam" ) $aItems[$iIndex] = StringReplace( $aItems[$iIndex], 3, StringFormat( "%03i", $iMaxTextLen ) ) EndIf Too narrow treeview control3) Store MaxTextLen.au3 is similar to the example above except that the treeview control is too narrow for the longest text strings. New 7z-file at bottom of first post. The first set of examples in 1) Virtual TreeView\ has all been updated with some very minor changes.
    1 point
  6. That means you haven't installed the full SciTE4AutoIt3 installer and are using the lite or portable version. The lite version is pretty fixed as far as configuration. Use the Full installer when you like to modify stuff and benefit from all its extra's.
    1 point
  7. Just be careful with the last line. If it does not have any \R (newline sequence) at the end, it will be included even if there is multiple occurrences of that line before...
    1 point
  8. Yes But if the purpose is to get for each paragraph the lines in a subarray then a 2nd step with StringSplit is needed StringRegExp with flag 4 could be used too but in this case the 'long' syntax (the OP's one in post #1) is unavoidable #include <Array.au3> $a = FileRead(@ScriptDir & "\Versions.log") $regexp = "(.+)\R(.+)\R(.+)\R(.+)\R(.+)\R" $a_regfind = StringRegExp($a,$regexp,4) For $i = 0 to 3 _ArrayDisplay($a_regfind[$i],"$a_registryfind") Next Why so much dogs mentioned around here ?
    1 point
  9. ..if you just searched the forum..
    1 point
  10. @leuce ! If you prefer arrays, then you could also consider _ArrayUnique : #include <File.au3> #include <Array.au3> Global $aArrSource, $aArrUnique If Not _FileReadToArray(@ScriptDir & "\testfile.txt", $aArrSource, $FRTA_NOCOUNT) Then Exit MsgBox(BitOR(4096, 16), "Message : ", "Error : _FileReadToArray") _ArraySort($aArrSource, Default, 0) ; optional : sort array $aArrUnique = _ArrayUnique($aArrSource, 0, 0, 1, $ARRAYUNIQUE_NOCOUNT) _FileWriteFromArray(@ScriptDir & "\testfile_unique.txt", $aArrUnique)
    1 point
  11. You were downloading the HTML for that URL instead of actual file. 😄
    1 point
  12. water

    OutlookEX UDF

    I think the OutlookEX UDF and the Outlook rule to forward mails use the same API. So what blocks the Outlook rule blocks the OutlookEX UDF as well. I think it would be best to talk to your IT-professionals. Maybe they use the Microsoft data classification system or other rules to block transferring mails to an EXTERNAL mailbox.
    1 point
  13. 1 point
  14. Jos

    OutlookEX UDF

    @Witcher Welcome.... I doubt the provided information is clear enough to be able to assist you. Show what you have now as a start and tell us what you mean by "blocked"....blocked where/by what? Jos
    1 point
  15. water

    OutlookEX UDF

    Please stop posting "Thank you!" just to push up your post count!
    1 point
  16. argumentum

    GuiChildTabUDF

    Version 1.2020.7.6

    456 downloads

    An example with Parent / child / child / children ... . It show examples of use GUIRegisterMsg(), etc. Read more about it on the thread.
    1 point
  17. guinness

    AutoIt Snippets

    Those who post vague questions are not only wasting their own time but also the time of those replying. So please provide the following to help those who help you. #include <Misc.au3> ; Version: 1.00. AutoIt: V3.3.8.1 ; Retrieve the recommended information of the current system when posting a support question. Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provide the details of my system:' & @CRLF & @CRLF & _ 'AutoIt Version: V' & @AutoItVersion & ' [' & _Iif(@AutoItX64, 'X64', 'X32') & ']' & @CRLF & _ 'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _ 'Language: ' & @OSLang & @CRLF & @CRLF & _ 'The following information has been copied to the clipboard. Use Ctrl + V to retrieve the following information.' MsgBox(4096, 'System Info', $sSystemInfo) ClipPut($sSystemInfo)
    1 point
×
×
  • Create New...