Jump to content

nobbitry

Active Members
  • Posts

    36
  • Joined

  • Last visited

Reputation Activity

  1. Like
    nobbitry reacted to TheDcoder in AutoIt Snippets   
    This functions lets you check if a window is responding or not. Equal to checking if a Window goes white after a while using your eye
    #include <WinAPISys.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: IsWindowNotResponding ; Description ...: Checks if a Window is not responding ; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000]) ; Parameters ....: $hWindow - A window handle. ; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000. ; Return values .: @error set by _WinAPI_SendMessageTimeout ; Author ........: Damon Harris (TheDcoder) ; Remarks .......: The way it works is that it exploits SendMessageTimeout's SMTO_ABORTIFHUNG option. ; Do more research on Process.Responding and how it works (C# function for checking if a window is responding) ; Link ..........: https://git.io/vbcvJ ; Example .......: If IsWindowNotResponding($hWindow) Then DoSomething() ; =============================================================================================================================== Func IsWindowNotResponding($hWindow, $iTimeout = 5000) _WinAPI_SendMessageTimeout($hWindow, 0, 0, 0, $iTimeout, $SMTO_ABORTIFHUNG) Return @error EndFunc
  2. Like
    nobbitry reacted to Jos in HotKey UDF   
    https://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F
     
  3. Like
    nobbitry reacted to MrCreatoR in OnAutoItErrorRegister - Handle AutoIt critical errors   
    AutoIt Version: 3.3.10.2+
    UDF Version: 2.0
    Description: This library allows to register function for AutoIt critical errors.
    Usually it's syntax errors, or array-related errors.
    By default the UDF shows custom debug dialog, although it is not possible to perform any real debugging, but we can for example display the error message, restart application, send bug report, or just close the application.
    Example #1 - Displaying built-in dialog when error is received:
    #NoTrayIcon #AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileClose(FileOpen('%scriptdir%\OAER_RAW_SRC.tmp', 2))" #AutoIt3Wrapper_Run_After=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileDelete('%scriptdir%\OAER_RAW_SRC.tmp')" #include <GUIConstantsEx.au3> #include 'OnAutoItErrorRegister.au3' _OnAutoItErrorRegister('', '', 'My App Error', False, False) GUICreate('OnAutoItErrorRegister Example', 350, 200) GUICtrlCreateLabel('This script is just an example.' & @CRLF & @CRLF & 'It will produce a syntax error in', 25, 40, 300, 50) GUICtrlCreateLabel('5', 185, 50, 50, 40) GUICtrlSetColor(-1, 0xF20000) GUICtrlSetFont(-1, 30, 800, 0, 'Tahoma') GUICtrlCreateLabel('seconds.', 220, 67, 300, 50) GUICtrlCreateLabel('The result shown as a CUSTOM error message, you can change it!', 25, 120, 350, 20) $iUnRegister_Bttn = GUICtrlCreateButton('UnRegister AutoItError handler', 25, 140, 200, 22) GUICtrlCreateLabel('Copyright jennico, G.Sandler (MrCreatoR) © 2008 - 2015', 25, 170, 350, 80) GUICtrlSetColor(-1, 0x808080) GUICtrlSetFont(-1, 8.5, 800, 6) GUISetState() Dim $iTimer For $i = 3 To 1 Step -1 GUICtrlSetData(4, $i) $iTimer = TimerInit() While TimerDiff($iTimer) < 1000 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iUnRegister_Bttn _OnAutoItErrorUnRegister() EndSwitch WEnd Next ;We deliberately make a syntax mistake and call the error! If Random(1, 5, 1) = 3 Then MsgBox(0, '', ) Else _NotExistingFunc() EndIf 
    Example #2 - Call user defined function when receiving error (script restart):
    #NoTrayIcon #AutoIt3Wrapper_Run_AU3Check=n ;!!! This must be used to ensure that raw source file is generated before compilation (because $bSetErrLine is True) #AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /BC_Strip #AutoIt3Wrapper_Run_After=%autoitdir%\AutoIt3.exe /AutoIt3ExecuteLine "FileDelete('%scriptdir%\OAER_RAW_SRC.tmp')" #pragma compile(Stripper, False) #include 'OnAutoItErrorRegister.au3' _OnAutoItErrorRegister('_MyErrorHandler', '', '', False, True) ;We deliberately make an array bounding error and call the error! Dim $aArr[1] MsgBox(0, '', $aArr[1]) Func _MyErrorHandler($sScriptPath, $iScriptLine, $sErrDesc, $vParams, $hBitmap) ;Restart the application Local $sMessage = StringFormat('SCRIPT FILE:\n%s\n\nSCRIPT ERROR LINE:\n%s\n\nERROR DESCRIPTION:\n%s', $sScriptPath, $iScriptLine, $sErrDesc) If StringInStr($CmdLineRaw, '/ErrorStdOut') Then If FileExists(@WindowsDir & "\Media\chord.wav") Then SoundPlay(@WindowsDir & "\Media\chord.wav") Else DllCall('user32.dll', 'int', 'MessageBeep', 'int', 0x00000010) EndIf EndIf If MsgBox(BitOR($MB_SYSTEMMODAL, $MB_YESNO), 'Crash recieved!', 'Restart application?' & @CRLF & @CRLF & $sMessage) <> 6 Then Return EndIf Local $sRunLine = @AutoItExe & ' "' & @ScriptFullPath & '"' If @Compiled Then $sRunLine = @ScriptFullPath EndIf Run($sRunLine, @ScriptDir) EndFunc 
    Download: OnAutoItErrorRegister.zip (Counter: )
     
    Screenshot:

    ChangeLog:
     
    Initial idea by jennico:
    Author(s): G.Sandler (MrCreatoR), jennico
    Notes:
    The UDF can not handle crashes that triggered by memory leaks, such as DllCall crashes, "Recursion level has been exceeded..." (when using hook method ($bUseStdOut = False)). When using StdOut method ($bUseStdOut = True), CUI not supported, and additional process executed to allow monitor for errors. After using _OnAutoItErrorUnRegister when $bUseStdOut = True, standard AutoIt error message will not be displayed on following syntax error. To use the "Send bug report" feature, there is need to fill related parameters (variables) under the «User Variables» section in UDF file (check the comments of these variables), or just build your own user function. [If $bSetErrLine is True...]                    Script must be executed before compilation (after any change in it), or use '#AutoIt3Wrapper_Run_Before=%autoitdir%\AutoIt3.exe "%in%" /BC_Strip' in your main script.
                       Do NOT use Au3Stripper when compiling the main script if you want correct error line detection for compiled script.
                       To get correct code line for compiled script, the script is transformed to raw source (merging includes) and FileInstall'ed when it's needed (on error),
                           therefore, the script is available in temp dir for few moments (when error is triggered), although it's crypted, but developer should ensure that his script is more protected.
    [If $bSetErrLine is False...]                    Use supplied GetErrLineCode.au3 to get proper error line code by line number from error that was triggered in compiled script.
  4. Like
  5. Like
    nobbitry got a reaction from Bou in Image Search Subscript used on on-accessible variable   
    @Bou, is it you?
     
  6. Like
    nobbitry reacted to LarsJ in Multi-line items in custom drawn ListView   
    Items in a standard listview in details/report view (this example deals only with listviews in details/report view) can display a single line of text. There seems not to be any options to change this. There is no word wrap option.
    If you search the forums, it's possible to find examples of listviews with multiple lines of text in each row. The multi-line items are implemented as owner drawn items through LVS_OWNERDRAWFIXED control style and WM_DRAWITEM messages.
    A problem with the owner drawn technique is that you are forced to draw everything yourself. Besides item texts and the background behind texts (white for non-selected items, dark blue for selected items with focus, button face for selected items without focus) you also have to draw checkboxes, images, icons and the background behind these elements yourself.
    Another technique is custom drawn listview items. Custom drawn items are implemented through NM_CUSTOMDRAW notifications included in WM_NOTIFY messages. NM_CUSTOMDRAW notifications are generated automatically by the code in ComCtl32.dll when the listview is updated. Implementing custom drawn items is a matter of responding to these messages or not. 
    The great advantage of custom drawn items is that the drawing process is divided into several stages. For a listview up to six different stages. Some of these stages can be used for default drawing without any additional code at all. Other stages can be used for custom drawing with your own code.
    Multi-line text items fits perfectly with the custom drawn technique. Item texts and the background is drawn by custom code. Checkboxes, images, icons and the background is drawn by default code.
    Increase height of listview items
    The usual way to increase the height of listview items is to respond to WM_MEASUREITEM messages. But this method can only be used for owner drawn listviews. In a custom drawn listview the height can be increased by defining a text font with a suitable height:
    Func _GUICtrlListView_SetItemHeightByFont( $hListView, $iHeight ) ; Get font of ListView control ; Copied from _GUICtrlGetFont example by KaFu ; See https://www.autoitscript.com/forum/index.php?showtopic=124526 Local $hDC = _WinAPI_GetDC( $hListView ), $hFont = _SendMessage( $hListView, $WM_GETFONT ) Local $hObject = _WinAPI_SelectObject( $hDC, $hFont ), $lvLOGFONT = DllStructCreate( $tagLOGFONT ) _WinAPI_GetObject( $hFont, DllStructGetSize( $lvLOGFONT ), DllStructGetPtr( $lvLOGFONT ) ) Local $hLVfont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) ; Original ListView font _WinAPI_SelectObject( $hDC, $hObject ) _WinAPI_ReleaseDC( $hListView, $hDC ) _WinAPI_DeleteObject( $hFont ) ; Set height of ListView items by applying text font with suitable height $hFont = _WinAPI_CreateFont( $iHeight, 0 ) _WinAPI_SetFont( $hListView, $hFont ) _WinAPI_DeleteObject( $hFont ) ; Restore font of Header control Local $hHeader = _GUICtrlListView_GetHeader( $hListView ) If $hHeader Then _WinAPI_SetFont( $hHeader, $hLVfont ) ; Return original ListView font Return $hLVfont EndFunc Large images will also increase the height of listview items. See example E.
    Height of listview
    If the height of the listview does not fit an integer number of rows, you can see empty space below last row in the bottom of the listview. This issue is exacerbated by tall items. The following function is used to calculate the height of the listview to match a given number of rows:
    Func _GUICtrlListView_GetHeightToFitRows( $hListView, $iRows ) ; Get height of Header control Local $tRect = _WinAPI_GetClientRect( $hListView ) Local $hHeader = _GUICtrlListView_GetHeader( $hListView ) Local $tWindowPos = _GUICtrlHeader_Layout( $hHeader, $tRect ) Local $iHdrHeight = DllStructGetData( $tWindowPos , "CY" ) ; Get height of ListView item 0 (item 0 must exist) Local $aItemRect = _GUICtrlListView_GetItemRect( $hListView, 0, 0 ) ; Return height of ListView to fit $iRows items ; Including Header height and 8 pixels of additional room Return ( $aItemRect[3] - $aItemRect[1] ) * $iRows + $iHdrHeight + 8 EndFunc The calculation includes the height of the header. This means that the function works for a multi-line header with tall items (example A and B).
    Reference example
    WM_NOTIFY messages and NM_CUSTOMDRAW notifications are send to the parent of the listview control. The parent is the AutoIt GUI and messages can be handled by a function registered with GUIRegisterMsg.
    Example 1 is a reference example which shows the different stages of the custom drawing process. None of the stages contains any code except for ConsoleWrite statements.
    This is code for the reference example:
    #include <GUIConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" Opt( "MustDeclareVars", 1 ) Global $hGui, $idListView, $hListView, $fListViewHasFocus = 0, $iItems = 3, $bAutoItMsgLoop = False Example() Func Example() ; Create GUI $hGui = GUICreate( "Custom draw stages", 420, 200 ) ; Create ListView $idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE+$LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES ) $hListView = GUICtrlGetHandle( $idListView ) ; Add columns to ListView _GUICtrlListView_AddColumn( $hListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $hListView, "Column 4", 94 ) ; Fill ListView For $i = 0 To $iItems - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows( $hListView, 10 ) WinMove( $hGui, "", Default, Default, Default, WinGetPos( $hGui )[3] - WinGetClientSize( $hGui )[1] + $iLvHeight + 20 ) WinMove( $hListView, "", Default, Default, Default, $iLvHeight ) ; Register WM_NOTIFY message handler ; To handle NM_CUSTOMDRAW notifications ; And to check when ListView receives/loses focus GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Register WM_ACTIVATE message handler ; If GUI loses focus selected listview items are drawn with a button face background color. ; To check when GUI receives/loses focus ; When GUI receives focus selected items are redrawn with the dark blue background color. GUIRegisterMsg( $WM_ACTIVATE, "WM_ACTIVATE" ) ; Detection of received focus is faster through the WM_ACTIVATE message than directly ; through the listview. This provides a faster and smoother redraw of selected items. ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If Not $bAutoItMsgLoop Then _ ; We want to see only one message at a time $bAutoItMsgLoop = ( ConsoleWrite( "AutoIt message loop <<<<<<<<<<<<<<<<<<<<<" & @CRLF ) > 0 ) WEnd ; Cleanup GUIDelete() EndFunc ; WM_NOTIFY message handler Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Local $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Local $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW $bAutoItMsgLoop = False Local $tNMLVCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Specifies the drawing stage ; Stage 1 Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "Stage 1: CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW + _ ; Stage 2 will be carried out $CDRF_NOTIFYPOSTPAINT ; Stage 6 will be carried out Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window before an item is painted Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after the paint cycle is complete ; Stage 2 Case $CDDS_ITEMPREPAINT ; Before an item is painted ConsoleWrite( "Stage 2: CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYSUBITEMDRAW + _ ; Stage 3 will be carried out $CDRF_NOTIFYPOSTPAINT ; Stage 5 will be carried out Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window before a subitem is painted Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after an item is painted ; Stage 3 Case BitOR( $CDDS_ITEMPREPAINT, _ $CDDS_SUBITEM ) ; Before a subitem is painted ConsoleWrite( "Stage 3: CDDS_ITEMPREPAINT, CDDS_SUBITEM" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Stage 4 will be carried out Return $CDRF_NOTIFYPOSTPAINT ; Notify the parent window after a subitem is painted ; Stage 4 Case BitOR( $CDDS_ITEMPOSTPAINT, _ $CDDS_SUBITEM ) ; After a subitem has been painted ConsoleWrite( "Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM" & @CRLF ) ; Stage 5 Case $CDDS_ITEMPOSTPAINT ; After an item has been painted ConsoleWrite( "Stage 5: CDDS_ITEMPOSTPAINT" & @CRLF ) ; Stage 6 Case $CDDS_POSTPAINT ; After the paint cycle is complete ConsoleWrite( "Stage 6: CDDS_POSTPAINT" & @CRLF ) EndSwitch Case $NM_KILLFOCUS If $fListViewHasFocus Then GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 0 EndIf Case $NM_SETFOCUS If Not $fListViewHasFocus Then _ GUICtrlSendMsg( $idListView, $LVM_REDRAWITEMS, 0, $iItems - 1 ) $fListViewHasFocus = 2 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ; WM_ACTIVATE message handler Func WM_ACTIVATE( $hWnd, $iMsg, $wParam, $lParam ) #forceref $iMsg, $lParam If $hWnd = $hGui Then _ $fListViewHasFocus = BitAND( $wParam, 0xFFFF ) ? 1 : 0 Return $GUI_RUNDEFMSG EndFunc Code is added to check when GUI and listview receives and loses focus. This is important in the other examples.
    Output in SciTE console immediately after example is opened:
    Stage 1: CDDS_PREPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 2: CDDS_ITEMPREPAINT Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 3: CDDS_ITEMPREPAINT,  CDDS_SUBITEM Stage 4: CDDS_ITEMPOSTPAINT, CDDS_SUBITEM Stage 5: CDDS_ITEMPOSTPAINT Stage 6: CDDS_POSTPAINT AutoIt message loop <<<<<<<<<<<<<<<<<<<<< Note that the entire custom draw process from stage 1 to 6 is not interrupted by the AutoIt message loop.
    The other examples are all based on the reference example.
    Examples
    This is common to all examples. First line in item texts is stored directly in the listview. Additional lines are stored in a global array named $aLines. Index in the array is item ID as returned by GUICtrlCreateListViewItem and stored in ItemParam internally in listview memory.
    Item texts and background is drawn with custom code. Other item elements and background is drawn with default code. In all examples LVS_SINGLESEL style is removed to be able to select multiple items.
    This is a picture of example E:

    Example 2, 3 and 4 are simple examples. Example 5 and 6 deals with subitem icons and colors.
    Example 7 about listview notifications shows a way to catch double click and Enter key. A dummy control is used to forward the double click event to AutoIt main message loop to avoid lengthy or blocking code in WM_NOTIFY function.
    Example 8 and 9 shows how to respond to header notifications and how to rearrange columns by dragging header items with the mouse. In both examples LVS_EX_HEADERDRAGDROP extended style is added to the listview.
    When columns are rearranged, header item index and listview subitem index is always the same independent of column position, while header item order changes depending on column position.
    Because the header is a child control of the listview, the listview must be subclassed to catch header notifications. Subclassing is implemented with the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (all implemented in WinAPIShellEx.au3). Since we are subclassing a header control contained in a listview this issue must be taking into account.
    Note that the subclass callback function is only running while the primary mouse button is pressed on the header. This means no performance impact on the listview eg. when you are dragging the scroll bar. This is important for a custom drawn listview.
    Quite a lot of extra code is added (most easily seen in example 9) to fix an issue due to column 0 and other columns have different left margins. When first column is moved to another position there is a white gap between columns for selected rows (Windows XP), or the text is painted too close to the left edge of the item (Windows 7). The problem is seen in the picture to the right where the two first columns are swapped:

    LVS_EX_HEADERDRAGDROP style is only used in example 8 and 9.
    Usage of a multi-line header is demonstrated in example A and B. See Custom/owner drawn multi-line header in ListView for more information.
    Example C shows a method to deal with focus issues when more controls (here just a single button) are added to the GUI. When the listview has focus selected items are drawn with the dark blue background color. The problem arises if the listview and GUI loses focus eg. to Calculator. When focus is lost selected items are drawn with the button face background color.
    If GUI receives focus again by clicking the button (and not the listview), selected items are first very briefly redrawn with the dark blue background color (it seems like a blink) and then with the correct button face background color. To avoid this issue a hidden label control is added to the GUI. Immediately before the GUI loses focus, focus is moved from the listview to the label.
    In example D items are added with the commands _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem. In all examples an array is used to store the multi-line item texts. The array contains all lines except the first line  which is stored directly in the listview. This example shows how to manually store array row index in ItemParam when items are added with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem.
    Inspiration for example E about large images in first column (see picture above) comes from this thread. In example E the images are used to increase the height of the listview items instead of a text font. Because it's large 128x128 pixel images there is plenty of room in subitems in second and third column.
    In all examples 15 lines of code is used to repaint the first line item text. The text that was painted by default code in middle of the item is first deleted by filling the item with the background color. Then the text is extracted from the listview and repainted in top of item. This code can be avoided by storing all text lines in the array. This is demonstrated in example F. This makes the custom draw code faster.
    Performance considerations
    In a custom drawn (or owner drawn or virtual) listview performance considerations are important because the custom drawing (or owner drawing or data display) is performed by AutoIt code. In a normal listview drawing and data display is performed by compiled C++ code in ComCtl32.dll.
    Lengthy and slow code in NM_CUSTOMDRAW Case statements (or WM_DRAWITEM functions or LVN_GETDISPINFO Case statements) should be avoided. Perform as many calculations as possible before the repetitive and fast executions of these code blocks. Use static variables to avoid repeating the same calculation again and again. Executing a function directly with DllCall or GUICtrlSendMsg is faster than executing the same function through an implementation in an UDF. Simple GDI functions are faster than more advanced GDI+ functions.
    Use different drawing stages to optimize custom drawing. The CDDS_PREPAINT stage is only performed once for the entire drawing process. The CDDS_ITEMPREPAINT stage is performed once per item. The stage given by BitOR( CDDS_ITEMPREPAINT, CDDS_SUBITEM ) is performed once per subitem including subitem 0. Default drawing should be used as much as possible, because the code is running in ComCtl32.dll.
    In a listview the time it takes to update all visible rows is proportional to the number of visible rows. Reducing the height of the list view and thus the number of visible rows improves performance. Especially in a custom drawn (or owner drawn or virtual) listview.
    ListviewMultilineItems.7z
    1) Custom draw stages.au3 2) Two-line listview items.au3 3) Three-line listview items.au3 4) First column checkbox and icon.au3 5) Check boxes and icons.au3 6) Background and text colors.au3 7) ListView notifications.au3 8) Header notifications.au3 9) Rearrange columns.au3 A) Multi-line header 1.au3 A) Multi-line header 2.au3 C) Button control.au3 D) _GUICtrlListView_AddItem.au3 E) Large images in first column.au3 F) Storing all lines in array.au3 GuiHeaderEx.au3 GuiListViewEx.au3 ListViewCustomDraw.au3 Images\ 8 images for example E You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit.
    Comments are welcome. Let me know if there are any issues.
    (Set tab width = 2 in SciTE to line up comments by column.)
    ListviewMultilineItems.7z
  7. Like
    nobbitry reacted to mLipok in OpenOffice/LibreOffice Spell Checker   
    @GMK Thanks for this Function, this is very handy !
    I just make a small modyfication for example:
    #include <MsgBoxConstants.au3> #include <Array.au3> #include <WinAPILocale.au3> Global $oMyError = ObjEvent('AutoIt.Error', '_ErrFunc') _Example() Func _Example() Local $sLocale = 'pl' Local $sCountry = 'PL' Local $sWord = InputBox("Spell Checker", "Type single word to check (empty for end) ?") While $sWord <> "" Global $vSpell = _OOo_SpellChecker($sWord, $sLocale, $sCountry) If @error Then MsgBox($MB_ICONERROR, '_OOo_SpellChecker', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ElseIf $vSpell Then MsgBox($MB_OK, "Spell Checker", $sWord & " is valid") Else If MsgBox($MB_YESNO, "Spell Checker", $sWord & " is NOT valid. Would you like to see alternatives?") = $IDYES Then Global $aAlternatives = _OOo_SpellChecker($sWord, $sLocale, $sCountry, True) _ArrayDisplay($aAlternatives, "Spell Checker") EndIf EndIf $sWord = InputBox("Spell Checker", "File to check (empty for end)?") WEnd EndFunc  
    ps.
    Try to not use magic numbers.
     
    EDIT:
    Small mod:
    Func _OOo_SpellChecker($sWord, $sLocale = 'en', $sCountry = 'US', $bShowAlternatives = False) Local Enum _ $eErr_Success, _ $eErr_GeneralError, _ $eErr_InvalidType, _ $eErr_InvalidValue, _ $eErr_NoMatch If Not IsString($sWord) Then Return SetError($eErr_InvalidType, 1, 0) If StringRegExp($sWord, '\d|\s') Or $sWord = '' Then Return SetError($eErr_InvalidValue, 1, 0) If Not IsString($sLocale) Then Return SetError($eErr_InvalidType, 2, 0) If StringLen($sLocale) <> 2 Then Return SetError($eErr_InvalidValue, 2, 0) If Not IsString($sCountry) Then Return SetError($eErr_InvalidType, 3, 0) If StringLen($sCountry) <> 2 Then Return SetError($eErr_InvalidValue, 3, 0) Local $oSM = ObjCreate('com.sun.star.ServiceManager') If Not IsObj($oSM) Then Return SetError($eErr_GeneralError, 10, 0) Local $oLocale = $oSM.Bridge_GetStruct('com.sun.star.lang.Locale') If Not IsObj($oLocale) Then Return SetError($eErr_GeneralError, 11, 0) $oLocale.Language = $sLocale $oLocale.Country = $sCountry Local $oLinguService = $oSM.createInstance('com.sun.star.linguistic2.LinguServiceManager') If Not IsObj($oLinguService) Then Return SetError($eErr_GeneralError, 12, 0) Local $oSpellChecker = $oLinguService.getSpellChecker If Not IsObj($oSpellChecker) Then Return SetError($eErr_GeneralError, 13, 0) If Not $oSpellChecker.hasLocale($oLocale) Then Return SetError($eErr_NoMatch, 2, 0) Local $oPropertyValue = $oSM.Bridge_GetStruct('com.sun.star.beans.PropertyValue') If Not IsObj($oPropertyValue) Then Return SetError($eErr_GeneralError, 14, 0) Local $aPropertyValue[1] = [$oPropertyValue] Local $nRandom = Random(0, 0.5) Local $bReturn = $oSpellChecker.isValid($sWord, $nRandom, $aPropertyValue) If @error Then Return SetError($eErr_GeneralError, 15, 0) If Not $bReturn And $bShowAlternatives Then Local $oSpell = $oSpellChecker.spell($sWord, $nRandom, $aPropertyValue) If Not IsObj($oSpell) Then Return SetError($eErr_GeneralError, 16, 0) Local $aReturn = $oSpell.getAlternatives() Local $iAlternatives = UBound($aReturn) ReDim $aReturn[$iAlternatives + 1] $iAlternatives += 1 For $i = $iAlternatives - 1 To 1 Step -1 $aReturn[$i] = $aReturn[$i - 1] Next $aReturn[0] = $oSpell.getAlternativesCount() If @error Then Return SetError($eErr_GeneralError, 17, 0) Return SetError($eErr_Success, 0, $aReturn) EndIf Return SetError($eErr_Success, 0, $bReturn) EndFunc ;==>_OOo_SpellChecker  
  8. Like
    nobbitry reacted to GMK in OpenOffice/LibreOffice Spell Checker   
    @mLipok asked me to come up with an AutoIt example for this.
    So here's what I came up with, including an added bonus.
    #include <Array.au3> Global $oMyError = ObjEvent('AutoIt.Error', '_ErrFunc') Global $sLocale = 'en' Global $sCountry = 'US' Global $sWord = InputBox("Spell Checker", "File to check (empty for end)?") While $sWord <> "" Global $vSpell = _OOo_SpellChecker($sWord, $sLocale, $sCountry) If $vSpell Then MsgBox(0, "Spell Checker", $sWord & " is valid") Else If MsgBox(4, "Spell Checker", $sWord & " is NOT valid. Would you like to see alternatives?") = 6 Then Global $aAlternatives = _OOo_SpellChecker($sWord, $sLocale, $sCountry, True) _ArrayDisplay($aAlternatives, "Spell Checker") EndIf EndIf $sWord = InputBox("Spell Checker", "File to check (empty for end)?") WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _OOo_SpellChecker ; Description ...: Checks a single word with the OpenOffice/LibreOffice spell checker to see if it is spelled correctly in a ; given locale. ; Syntax ........: _OOo_SpellChecker($sWord[, $sLocale = 'en'[, $sCountry = 'US'[, $bShowAlternatives = False]]]) ; Parameters ....: $sWord - a string value. ; $sLocale - [optional] a string value. Default is 'en'. ; $sCountry - [optional] a string value. Default is 'US'. ; $bShowAlternatives - [optional] a boolean value. Default is False. ; Return values .: On Success - Returns True if the word is spelled correctly using the specified language, False ; otherwise. If word is not spelled correctly and $bShowAlternatives is set to True, ; an array of suggestions is returned. ; On Failure - Returns 0 and sets @error and @extended: ; | @error = 0 - Success (No error) ; | 1 - General error ; | 2 - Invalid type ; | 3 - Invalid value ; | 4 - No match found ; | @extended = number of offending parameter ; Author ........: GMK ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellChecker.html ; https://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellAlternatives.html ; http://www.loc.gov/standards/iso639-2/php/code_list.php ; https://www.iso.org/obp/ui/#search ; Example .......: Yes ; =============================================================================================================================== Func _OOo_SpellChecker($sWord, $sLocale = 'en', $sCountry = 'US', $bShowAlternatives = False) Local Enum $eErr_Success, _ $eErr_GeneralError, _ $eErr_InvalidType, _ $eErr_InvalidValue, _ $eErr_NoMatch If Not IsString($sWord) Then Return SetError($eErr_InvalidType, 1, 0) If StringRegExp($sWord, '\d|\s') Then Return SetError($eErr_InvalidValue, 1, 0) If Not IsString($sLocale) Then Return SetError($eErr_InvalidType, 2, 0) If StringLen($sLocale) <> 2 Then Return SetError($eErr_InvalidValue, 2, 0) If Not IsString($sCountry) Then Return SetError($eErr_InvalidType, 3, 0) If StringLen($sCountry) <> 2 Then Return SetError($eErr_InvalidValue, 3, 0) Local $oSM = ObjCreate('com.sun.star.ServiceManager') If Not IsObj($oSM) Then Return SetError($eErr_GeneralError, 10, 0) Local $oLocale = $oSM.Bridge_GetStruct('com.sun.star.lang.Locale') If Not IsObj($oLocale) Then Return SetError($eErr_GeneralError, 11, 0) $oLocale.Language = $sLocale $oLocale.Country = $sCountry Local $oLinguService = $oSM.createInstance('com.sun.star.linguistic2.LinguServiceManager') If Not IsObj($oLinguService) Then Return SetError($eErr_GeneralError, 12, 0) Local $oSpellChecker = $oLinguService.getSpellChecker If Not IsObj($oSpellChecker) Then Return SetError($eErr_GeneralError, 13, 0) If Not $oSpellChecker.hasLocale($oLocale) Then Return SetError($eErr_NoMatch, 2, 0) Local $oPropertyValue = $oSM.Bridge_GetStruct('com.sun.star.beans.PropertyValue') If Not IsObj($oPropertyValue) Then Return SetError($eErr_GeneralError, 14, 0) Local $aPropertyValue[1] = [$oPropertyValue] Local $nRandom = Random(0, 0.5) Local $bReturn = $oSpellChecker.isValid($sWord, $nRandom, $aPropertyValue) If @error Then Return SetError($eErr_GeneralError, 15, 0) If Not $bReturn And $bShowAlternatives Then Local $oSpell = $oSpellChecker.spell($sWord, $nRandom, $aPropertyValue) If Not IsObj($oSpell) Then Return SetError($eErr_GeneralError, 16, 0) Local $aReturn = $oSpell.getAlternatives() Local $iAlternatives = UBound($aReturn) ReDim $aReturn[$iAlternatives + 1] $iAlternatives += 1 For $i = $iAlternatives - 1 To 1 Step -1 $aReturn[$i] = $aReturn[$i - 1] Next $aReturn[0] = $oSpell.getAlternativesCount() If @error Then Return SetError($eErr_GeneralError, 17, 0) Return SetError($eErr_Success, 0, $aReturn) EndIf Return SetError($eErr_Success, 0, $bReturn) EndFunc Func _ErrFunc($oError) ConsoleWrite(@ScriptName & ' (' & $oError.scriptline & ') : ==> COM Error intercepted !' & @CRLF & _ @TAB & 'err.number is: ' & @TAB & @TAB & '0x' & Hex($oError.number) & @CRLF & _ @TAB & 'err.windescription:' & @TAB & $oError.windescription & @CRLF & _ @TAB & 'err.description is: ' & @TAB & $oError.description & @CRLF & _ @TAB & 'err.source is: ' & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & 'err.helpfile is: ' & @TAB & $oError.helpfile & @CRLF & _ @TAB & 'err.helpcontext is: ' & @TAB & $oError.helpcontext & @CRLF & _ @TAB & 'err.lastdllerror is: ' & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & 'err.scriptline is: ' & @TAB & $oError.scriptline & @CRLF & _ @TAB & 'err.retcode is: ' & @TAB & '0x' & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc  
  9. Like
    nobbitry got a reaction from phuocvovan in Image Search Subscript used on on-accessible variable   
    Hey @phuocvovan,
    Look at the your error message. There you can read, in which file and in which line the error occurs. Why don't you try out, what I wrote.
    Maybe ist doesn't help. You will know, when you try it
  10. Like
    nobbitry got a reaction from phuocvovan in Image Search Subscript used on on-accessible variable   
    I have no solution for your problem, but I Think you didn't understand what was meant here:
    You check if $test is an Array. I think the Function never gives an array back. So this test is no help.
     
    Func _test() $test = _ImageSearch($ImgWindowsOrange, 0, $X, $Y, 0) If IsArray($test) Then _ArrayDisplay($test, "test") Else MsgBox(0, "test", $test) EndIf EndFunc ;==>_test You need to insert InunoTaishou's line above the line where the error occur.
  11. Like
    nobbitry got a reaction from Bou in Imagesearch problem   
    Do you work with a 64bit windows?
    Maybe you have to add "#AutoIt3Wrapper_UseX64 = Y" on the top of your script.
    #AutoIt3Wrapper_UseX64 = Y #include <imagesearch.au3> HotKeySet('=', 'start') $x = 0 $y = 0 Func Start() $search = _ImageSearch('capture.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y, 10) EndIf EndFunc ;==>Start While 1 Sleep(100) WEnd  
  12. Like
    nobbitry reacted to czardas in Question to Constants of WinGetState   
    Apparently this has already been amended: https://www.autoitscript.com/trac/autoit/ticket/3116
    I'm running a slightly older version of AutoIt, but I'm sure they will be included in the next release.
  13. Like
    nobbitry reacted to jguinch in Code to extract plain text from a PDF file   
    I have already made something like this...
    Download the XPDF tools (pdfinfo and pdftotext.) and try my script :
    ; #FUNCTION# ==================================================================================================================== ; Name...........: _XFDF_Info ; Description....: Retrives informations from a PDF file ; Syntax.........: _XFDF_Info ( "File" [, "Info"] ) ; Parameters.....: File - PDF File. ; Info - The information to retrieve ; Return values..: Success - If the Info parameter is not empty, returns the desired information for the specified Info parameter ; - If the Info parameter is empty, returns an array with all available informations ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external programm ; Remarks........: The array returned is two-dimensional and is made up as follows: ; $array[1][0] = Label of the first information (title, author, pages...) ; $array[1][1] = value of the first information ; ... ; =============================================================================================================================== Func _XFDF_Info($sPDFFile, $sInfo = "") Local $sXPDFInfo = @ScriptDir & "\pdfinfo.exe" If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFInfo) Then Return SetError(2, 0, 0) $sXPDFInfo = FileGetShortName($sXPDFInfo) Local $iPid = Run(@ComSpec & ' /c ' & $sXPDFInfo & ' "' & $sPDFFile & '"', @ScriptDir, @SW_HIDE, 2) Local $sResult While 1 $sResult &= StdoutRead($iPid) If @error Then ExitLoop WEnd Local $aInfos = StringRegExp($sResult, "(?m)^(.+?): +(.*)$", 3) If @error Or Mod( UBound($aInfos, 1), 2) = 1 Then Return SetError(3, 0, 0) Local $aResult [ UBound($aInfos, 1) / 2][2] For $i = 0 To UBound($aInfos) - 1 Step 2 If $sInfo <> "" AND $aInfos[$i] = $sInfo Then Return $aInfos[$i + 1] $aResult[$i / 2][0] = $aInfos[$i] $aResult[$i / 2][1] = $aInfos[$i + 1] Next If $sInfo <> "" Then Return "" Return $aResult EndFunc ; ---> _XFDF_Info ; #FUNCTION# ==================================================================================================================== ; Name...........: _XPDF_Search ; Description....: Retrives informations from a PDF file ; Syntax.........: _XFDF_Info ( "File" [, "String" [, Case = 0 [, Flag = 0 [, FirstPage = 1 [, LastPage = 0]]]]] ) ; Parameters.....: File - PDF File. ; String - String to search for ; Case - If set to 1, search is case sensitive (default is 0) ; Flag - A number to indicate how the function behaves. See below for details. The default is 0. ; FirstPage - First page to convert (default is 1) ; LastPage - Last page to convert (default is 0 = last page of the document) ; Return values..: Success - ; Flag = 0 - Returns 1 if the search string was found, or 0 if not ; Flag = 1 - Returns the number of occcurrences found in the whole PDF File ; Flag = 2 - Returns an array containing the number of occurrences found for each page ; (only pages containing the search string are returned) ; $array[0][0] - Number of matching pages ; $array[0][1] - Number of occcurrences found in the whole PDF File ; $array[n][0] - Page number ; $array[n][1] - Number of occcurrences found for the page ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external programm ; =============================================================================================================================== Func _XPDF_Search($sPDFFile, $sSearch, $iCase = 0, $iFlag = 0, $iStart = 1, $iEnd = 0) Local $sXPDFToText = @ScriptDir & "\pdftotext.exe" Local $sOptions = " -layout -f " & $iStart Local $iCount = 0, $aResult[1][2] = [[0, 0]], $aSearch, $sContent, $iPageOccCount If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFToText) Then Return SetError(2, 0, 0) If $iEnd > 0 Then $sOptions &= " -l " & $iEnd Local $iPid = Run($sXPDFToText & $sOptions & ' "' & $sPDFFile & '" -', @ScriptDir, @SW_HIDE, 2) While 1 $sContent &= StdoutRead($iPid) If @error Then ExitLoop WEnd Local $aPages = StringSplit($sContent, chr(12) ) For $i = 1 To $aPages[0] $iPageOccCount = 0 While StringInStr($aPages[$i], $sSearch, $iCase, $iPageOccCount + 1) If $iFlag <> 1 AND $iFlag <> 2 Then $aResult[0][1] = 1 ExitLoop EndIf $iPageOccCount += 1 WEnd If $iPageOccCount Then Redim $aResult[ UBound($aResult, 1) + 1][2] $aResult[0][1] += $iPageOccCount $aResult[0][0] = UBound($aResult) - 1 $aResult[ UBound($aResult, 1) - 1 ][0] = $i + $iStart - 1 $aResult[ UBound($aResult, 1) - 1 ][1] = $iPageOccCount EndIf Next If $iFlag = 2 Then Return $aResult Return $aResult[0][1] EndFunc ; ---> _XPDF_Search ; #FUNCTION# ==================================================================================================================== ; Name...........: _XPDF_ToText ; Description....: Converts a PDF file to plain text. ; Syntax.........: _XPDF_ToText ( "PDFFile" , "TxtFile" [ , FirstPage [, LastPage [, Layout ]]] ) ; Parameters.....: PDFFile - PDF Input File. ; TxtFile - Plain text file to convert to ; FirstPage - First page to convert (default is 1) ; LastPage - Last page to convert (default is last page of the document) ; Layout - If true, maintains (as best as possible) the original physical layout of the text ; If false, the behavior is to 'undo' physical layout (columns, hyphenation, etc.) ; and output the text in reading order. ; Default is True ; Return values..: Success - 1 ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external program ; =============================================================================================================================== Func _XPDF_ToText($sPDFFile, $sTXTFile, $iFirstPage = 1, $iLastPage = 0, $bLayout = True) Local $sXPDFToText = @ScriptDir & "\pdftotext.exe" Local $sOptions If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFToText) Then Return SetError(2, 0, 0) If $iFirstPage <> 1 Then $sOptions &= " -f " & $iFirstPage If $iLastPage <> 0 Then $sOptions &= " -l " & $iLastPage If $bLayout = True Then $sOptions &= " -layout" Local $iReturn = ShellExecuteWait ( $sXPDFToText , $sOptions & ' "' & $sPDFFile & '" "' & $sTXTFile & '"', @ScriptDir, "", @SW_HIDE) If $iReturn = 0 Then Return 1 Return 0 EndFunc ; ---> _XPDF_ToText Original post on the french forum
  14. Like
    nobbitry reacted to Allow2010 in _FB_Tools - manage your FritzBox from Autoit   
    _FB_Tools
    The German company AVM (http://en.avm.de/) sells a router with many extra functions. This router is called FritzBox and comes in different models.
    Some models have more features than others, but all have a web-interface to control the features. _FB_Tools allows to control this web-interface by reading settings from the generated webpages and settings functions based on those settings. But as the web-interface changes from model to model and from firmware version to firmware version _FB_Tools needs to be constantly modified to work with the latest firmware.
    Currently I only use the FritzBox model 7490 http://en.avm.de/products/fritzbox/fritzbox-7490/ and i only test with this model. Other models may or may not work out of the box, but if a functions does not work, it is in most cases easy to modify the code to read and send commands for your model.
     _FB_Tools can help with home automation tasks, like switching WLAN, GuestWLAN, or GuestLAN functions, or DECT (wireless phones) functions.
    You can also dial numbers or work with phone-books, change settings of an answering machine or upload audio files to it.
    The ZIP also includes a simple test and demo tool.

    _FB_Tools_old.zip
    _FB_Tools_1.636-31656.zip
  15. Like
    nobbitry reacted to UEZ in Trying to set text color on a radio button control   
    Another old example which I found on my disk:
    #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 324, 222, 192, 124) $Radio1 = GUICtrlCreateRadio("", 104, 72, 14, 17) ;~ DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Radio1), "wstr", 0, "wstr", 0) $Label = GUICtrlCreateLabel("Radio One", 121, 70, 100, 17) $hLabel = GUICtrlGetHandle($Label) GUICtrlSetFont(-1, 12, 400, 0, "Palatino Linotype") GUICtrlSetColor(-1, 0xFF0000) $Radio2 = GUICtrlCreateRadio("Radio Two", 104, 110, 113, 17) GUICtrlSetFont(-1, 12, 400, 0, "Palatino Linotype") GUICtrlSetColor(-1, 0xFF0000) GUISetState(@SW_SHOW) Global $hLabelWndProc = DllCallbackRegister("LabelWndProc", "long", "hwnd;uint;wparam;lparam") Global $hOldLabelProc = _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, DllCallbackGetPtr($hLabelWndProc)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, $hOldLabelProc) DllCallbackFree($hLabelWndProc) GUIDelete() Exit EndSwitch WEnd Func LabelWndProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_LBUTTONDOWN GUICtrlSetState($Radio1, $GUI_CHECKED) GUICtrlSetState($Radio2, $GUI_UNCHECKED) ControlFocus($Form1, "", $Label) EndSwitch Return _WinAPI_CallWindowProc($hOldLabelProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>EditWndProc  
  16. Like
    nobbitry reacted to Melba23 in GUIListViewEx - New Version 11Dec 24   
    [New VERSION] - 11 Dec 24
    Added: New function _GUIListViewEx_EditProcessActive which returns the handle of the ListView concerned if an element is being edited. Usage scenario: prevent HotKeys from working when editing is underway.
    Fixed: A couple of bugs with columns: added columns were automatically sortable; dragging columns meant editing pop-up could appear in wrong place. Thanks to ValentinM for the reports.
    New UDF in the zip below.
    --------------------------------------------------------------------------------------
    Note: This is a new recoded and expanded version of my earlier UDF of the same name. If you move to this new version there might well be several script-breaking changes, particularly when setting which columns are to be editable. Please read the "Beginner's Guide" and look at the included example scripts to see where things have changed.
    --------------------------------------------------------------------------------------
    This UDF allows you to do much more with ListView controls (either native or UDF created):
    Edit the content with plain text, combos or date-time pickers - and edit the headers too Move rows within the ListView Drag rows both within the ListView and to other ListViews in the same GUI (or not as required) Insert and delete columns and rows Sort columns by simply clicking the header Colour individual ListView items and headers Only select a single cell rather then the entire row Save and load entire ListViews For the advanced user: If you use certain Windows message handlers (In particular WM_NOTIFY) in your script, please read the function headers for the equivalent handlers within the UDF.
    Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip
    Credit to: martin (basic drag code), Array.au3 authors (array functions), KaFu and ProgAndy (font function), LarsJ (colouring code)
    Happy to take compliments or criticism - preferably the former!
    M23
  17. Like
    nobbitry reacted to Melba23 in Problem in function _ArrayUnique, crash   
    Massi,
    I thought we had fixed that in 3.3.14.2 - the line should read:
    Local $vFirstElem = ( ($iDims = 1) ? ($aArray[$iBase]) : ($aArray[$iBase][$iColumn]) ) and yet it still reads the other way round when I look in the file. So it will crash when the column value is higher that the number of rows in the array - although it still checks the correct column if that is not the case.  I am beginning to seriously dislike this function...........
    Looking in SVN it has been further modified to use an If structure rather than a ternary (which is a pity) and it is still the wrong way around. I will fix it now so it is ready for the next release.
    M23
    Edit: And done - apologies again.
  18. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    [NEW VERSION] - 9 Feb 15

    Changed: Previous changes led to unwanted behaviour when dropping to the empty space below existing items in other ListViews. Now dropping items into the empty space will automatically place the item at the end of the list.

    Thanks to nobbitry for the report and the nudge to get it working intuitively.

    New UDF in the first post.

    M23
  19. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    nobbitry,

    Glad you like it - and I think the new behaviour is more intuitive as well.

    M23
  20. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    nobbitry,

    I try to give good service!

    I will look and see how hard it would be to add the dropped items at the end of the list - but no promises.

    M23

    Edit:

    Easier than I though it would be:
    <snip>
  21. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    nobbitry,

    The law of unintended consequences strikes again!

    I have amended the UDF code so that you can drop into empty space within another ListView but not drag there within the original - please try it and let me know if it allows you to do what you require:
    <snip>

    How is that?

    M23
  22. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    [NEW VERSION] - 13 Oct 14

    Added: You can now decide whether to delete or retain the items dragged to another ListView. So that the user can prevent items being dragged back into the ListView if they were not deleted and so creating multiple entries, this change has also forced the change in behaviour below.

    Changed: The ability to prevent external drag and drop operations has now been split into separate drag/drop parameters. This is script-breaking if you had previously blocked ListViews from external drag/drop operations - but as it only involves adding another value to the $iAdded parameter it is not difficult to fix.

    Thanks to nobbitry for the suggestion.

    New UDF in the first post.

    M23
  23. Like
    nobbitry reacted to Melba23 in GUIListViewEx - Deprecated Version   
    Now replaced by a new version of the UDF in this link.
    <hr>
    [NEW VERSION] - 7 Mar 16
    Added:
    A new option for $iAdded (+ 512) allows you to select just one cell of the ListView rather than the whole row. A new function _GUIListViewEx_SetDefColours allows the user to set the default colours when using either or both the "colour" and "single cell selection" options. Another new function _GUIListViewEx_BlockReDraw which prevents ListView redrawing during looped Insert/Delete/Change calls - this greatly speeds up execution by avoiding lengthy redrawing when using either or both the "colour" and "single cell selection" options, use of which forces the redraw to use a WM_NOTIFY handler within the script. Changed:
    A number of minor internal changes to speed up the loading of the ListView when using either or both of the "colour" and "single cell selection" options. A slightly modified Example_6 script shows the new functions in use. The LH native ListView can have rows and columns added/removed using both the old and new functions and has a context menu to allow for colour selection. The contents of this ListView can be mirrored to the RH UDF-created ListView which has "single cell selection" enabled and allows the colours of any item (including the selected cell) to be changed programmatically.
    New UDF in the zip below.
    Previous changes: ChangeLog.txt
     
    Hi,
    It seemed that I wanted to add, delete, edit or move items in a ListView quite often in my scripts and I got fed up with having to rewrite the code to do it each time. I also wanted to be able to drag items within and between ListViews with the mouse, plus edit the items. So I decided to write a UDF to make life easier and here is the result - GUIListViewEx.
    If you are interested in how it works, then read this bit - if not, then skip over it:
    The UDF is pretty easy to use:
    - You start by creating a ListView (either native or UDF) and passing the returned ControlID/handle and the array you used to fill it to the _Init function of the UDF. You also indicate whether the array has a count in the [0] (or [0][0]) element and if you create an empty ListView, the UDF will still cope and will shadow any items that you insert later. If you have a ListView filled with data but no matching array, there is a function to read that data into an array for you. You can select a colour for the insert mark when dragging items if you are going to use this feature - the default is black - and decide whether to have a shadow of the dragged item follow the mouse. Finally you can set the ListView to be sortable, editable - with various options to determine how the editing process works, determine external drag/drop behaviour and  whether user colours are used.
    - You need to register a few Windows messages, but this is a single call to the _MsgRegister function. If you already have handlers for the relevant messages, there are functions to call within these handlers instead. If you do not want to drag, then you only need the WM_NOTIFY handler loaded.
    - Then you just need to call the main _Insert($vData), _Delete, _Up, and _Down functions when the appropriate button is pressed, select and drag items, or use one of the edit functions and your ListView responds automatically.
    - The UDF shadows the contents of the ListView (as explained in the spoiler section above) so you can get its current state at any time with the _ReturnArray function . Many of the functions actually return this data after each call just to help you keep track and there are dedicated Save/Load functions.
    - If enabled, the user can colour individual items within the ListView - and can set certain elements to be coloured on loading if required.
     - There are a couple of functions that you need to run in your idle loop if you need the functionality - they detect when items are dragged and edited.
    - When you have finished with the ListView, you should use the _Close function to clear the memory used by the UDF to shadow its contents. It is not vital, but if you use a lot of ListViews and do not do this, you could end up running out of memory.
    - You can have as many ListViews as you wish on display at any one time and the same "Insert", "Delete", "Up" and "Down" buttons can be used for them all - you just have to click on the one you want to be active. The UDF also allows you to set the active ListView programatically (_SetActive) - and to determine which is currently active (_GetActive). There are also additional Insert/DeleteSpec functions which allow you to action non-active ListViews.
    There are 6 example scripts to show the UDF working on native and UDF created ListViews, with single or multiple columns and either filled or empty, along with the UDF itself in this zip file: 
    Credit to martin (for the basic drag code which I found on the forum), the Array UDF authors (for the basis of the array functions) and LarsJ (for the basic colour handler code).
    Happy for any feedback - hopefully positive!
    M23
  24. Like
    nobbitry reacted to Melba23 in Restrict GUI Resize with Minimal Dimensions   
    DarkBoost,

    Easy when you know how!

    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 300, $GUIMINHT = 100;set your restrictions here Global $GUIMAXWID = 800, $GUIMAXHT = 500 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $aPos = WinGetPos($hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE ;WinMove($hGUI, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID ); max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT ) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO All clear?

    M23
×
×
  • Create New...