Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/17/2013 in all areas

  1. 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
    1 point
  2. Why do you want to "call" it from outside the loop. Please have a look at the help file for function GUICreate. The example shows how to code a GUI. Or have a look at the tutorials in the wiki.
    1 point
  3. Jon

    AutoIt v3.3.9.17 Beta

    Clusters are optional, the "fast" flag just reverses code points.
    1 point
  4. MHz

    Constants vs Variables

    It is because a const in AutoIt is a read only variable as I was informed in the past. There is little advantage other then the Do-Not-Change-My-Value behavior. Quote from myself from here about const.
    1 point
  5. To explain the problem, the Windows clipboard can hold multiple content types at the same time. Most applications only bother with plaintext, but rich text, HTML, bitmaps, and many others are all valid formats that can exist with the plaintext in the clipboard. Content aware clipboard readers will allow you to pick between multiple formats if the destination accepts them.
    1 point
  6. You shouldn't complicate file header. Data there should be absolute minimum needed for identification, or better said verification (considering you write for Windows) of the format. Look for PNG file format specification to see what modern and completely forward compatible file format looks like. Avoid formats of for example, doc files (Yashied). That's from some old passed times. On Windows all you really need is file extension.
    1 point
  7. alfianpradana, Of course - it is extremely simple: Func Button11() ShellExecute("https://www.facebook.com") EndFunc M23
    1 point
  8. Jos

    Connect to yahoo mail

    The linked UDF is merely for sending Emails. Yahoo works too with that UDF. Take your time to read through some of the posted code and try to understand it as it isn't really that difficult. Jos
    1 point
  9. This answer will be extreme: If your code is well written, no AutoIt Error messagebox will ever show up.
    1 point
  10. Was waiting for chicken to cook, so I combined them for you: #RequireAdmin If DisplayChangeRes(1920, 1080, 32, 60) = 0 Then MsgBox(0, "Error", "Invalid resolution selected") Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ) If CheckDisplay($WIDTH, $HEIGHT, $BPP, $FREQ) = 0 Then Return 0 EndIf $DM_PELSWIDTH = 0x00080000 $DM_PELSHEIGHT = 0x00100000 $DM_BITSPERPEL = 0x00040000 $DM_DISPLAYFREQUENCY = 0x00400000 $CDS_TEST = 0x00000002 $CDS_UPDATEREGISTRY = 0x00000001 $DISP_CHANGE_RESTART = 1 $DISP_CHANGE_SUCCESSFUL = 0 $HWND_BROADCAST = 0xffff $WM_DISPLAYCHANGE = 0x007E $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) If @error Then $B = 0 Else $B = $B[0] EndIf If $B <> 0 Then DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) DllStructSetData($DEVMODE, 4, $WIDTH, 2) DllStructSetData($DEVMODE, 4, $HEIGHT, 3) DllStructSetData($DEVMODE, 4, $BPP, 1) DllStructSetData($DEVMODE, 4, $FREQ, 5) $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) If @error Then $B = -1 Else $B = $B[0] EndIf Select Case $B = $DISP_CHANGE_RESTART $DEVMODE = "" Return 2 Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" Return $B EndSelect EndIf Return 1 EndFunc ;==>DisplayChangeRes Func CheckDisplay($w, $h, $bit, $f) $flag = 0 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\") $colItems = $objWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $w = $objItem.HorizontalResolution And $h = $objItem.VerticalResolution And 2^$bit = $objItem.NumberOfColors And $f = $objItem.RefreshRate Then $flag = 1 Next EndIf Return $flag EndFunc ;==>CheckDisplay
    1 point
×
×
  • Create New...