Leaderboard
Popular Content
Showing content with the highest reputation on 04/18/2013 in all areas
-
GUIListViewEx - Deprecated Version
123disconnect reacted to Melba23 for a topic
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! M231 point -
Check whether a GUID is valid. You may only need to copy one function only. Source: https://en.wikipedia.org/wiki/Guid Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsGUID ; Description ...: Check whether a GUID string is valid. ; Syntax ........: _IsGUID($sString) ; Parameters ....: $sString - Check a GUID string with or without brackets is valid. ; Return values .: Success: True ; Failure: False ; Author ........: guinness ; Remarks .......: SRE: http://mitchelsellers.com/blogs/2007/04/22/validating-a-guid-value-with-regular-expressions.aspx ; Example .......: Yes ; =============================================================================================================================== Func _IsGUID($sString) Return StringRegExp($sString, '^(?:(?<curly>\{)?[0-9A-Fa-f]{8}-(?:[0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}(?(curly)\}))$') > 0 EndFunc ;==>_IsGUIDFunction: (Different approach) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsGUID ; Description ...: Check whether a GUID string is valid. ; Syntax ........: _IsGUID($sString) ; Parameters ....: $sString - Check a GUID string with or without brackets is valid. ; Return values .: Success: True ; Failure: False ; Author ........: guinness ; Remarks .......: SRE: http://mitchelsellers.com/blogs/2007/04/22/validating-a-guid-value-with-regular-expressions.aspx ; Example .......: Yes ; =============================================================================================================================== Func _IsGUID($sString) Return StringRegExp($sString, '^(?:(?<curly>\{)?[[:xdigit:]]{8}-(?:[[:xdigit:]]{4}-){3}[[:xdigit:]]{12}(?(curly)\}))$') > 0 EndFunc ;==>_IsGUIDExample use of Function: Example() Func Example() Local $sGUID = CreateGUID() ; Or _WinAPI_CreateGUID() from WinAPIEx.au3. ConsoleWrite($sGUID & ': ' & _IsGUID($sGUID) & @CRLF) $sGUID = '{EBEB-642D-11E2-B009-B121}' ConsoleWrite($sGUID & ': ' & _IsGUID($sGUID) & @CRLF) $sGUID = '{E25F2E50-6497-11E2-BE9E-182679957A39}' ConsoleWrite($sGUID & ': ' & _IsGUID($sGUID) & @CRLF) $sGUID = 'EF3391DE-6497-11E2-B99A-182679957A39' ConsoleWrite($sGUID & ': ' & _IsGUID($sGUID) & @CRLF) EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: CreateGUID ; Description ...: Create a valid GUID. ; Syntax ........: CreateGUID() ; Parameters ....: None ; Return values .: Success: GUID string ; Failure: Empty string and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func CreateGUID() ; Converted from a VBScript I had. Local $oTypeLib = ObjCreate('Scriptlet.TypeLib') If IsObj($oTypeLib) = 0 Then Return SetError(1, 0, '') EndIf Return StringLeft($oTypeLib.Guid, 38) EndFunc ;==>CreateGUID1 point
-
This simple regular expression I came across on regexlib.com, will verify if a colour value is a "web safe" colour value. I have used color in the function instead of colour, to match that of AutoIt's use of the American term(s). Function and Example: #include <Constants.au3> MsgBox($MB_SYSTEMMODAL, '', '#FFFFFF: ' & _IsWebColor('#FFFFFF')) MsgBox($MB_SYSTEMMODAL, '', '#EEFFCC: ' & _IsWebColor('#EEFFCC')) MsgBox($MB_SYSTEMMODAL, '', '0x000033: ' & _IsWebColor('0x000033')) MsgBox($MB_SYSTEMMODAL, '', '000033: ' & _IsWebColor('000033')) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _IsWebColor ; Description ...: Check whether a color value is a valid web color. Onl ; Syntax ........: _IsWebColor($sColor) ; Parameters ....: $sColor - Valid web color. ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Related .......: http://html-color-codes.com/ ; Link ..........: http://www.regexlib.com/REDetails.aspx?regexp_id=528 ; Example .......: Yes ; =============================================================================================================================== Func _IsWebColor($sColor) Return StringRegExp($sColor, '^(?:#|0[xX])?(([FfCc0369])\2){3}$') = 1 ; Also valid: (?i)^#?(([fc0369])\2){3}$ EndFunc ;==>_IsWebColor1 point
-
For those who enjoy using ListViews and wish to export the data to a Txt file, then this function is for you. Function without an array: #include <Constants.au3> #include <GUIListView.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_SaveTxt ; Description ...: Exports a listview to a txt file. ; Syntax ........: _GUICtrlListView_SaveTxt($hListView, $sFilePath[, $sDelimiter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sFilePath - Filepath to save the txt data string to. ; $sDelimiter - [optional] Delimiter to distinguish between columns. Default is |. ; Return values .: Success - True ; Failure - False and sets @error to non-zero. ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_SaveTxt($hListView, $sFilePath, $sDelimiter = '|') If $sDelimiter = Default Then $sDelimiter = '|' EndIf Local Const $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) - 1 Local Const $iItemCount = _GUICtrlListView_GetItemCount($hListView) - 1 Local $sReturn = '' For $i = 0 To $iItemCount For $j = 0 To $iColumnCount $sReturn &= _GUICtrlListView_GetItemText($hListView, $i, $j) If $j < $iColumnCount Then $sReturn &= $sDelimiter EndIf Next $sReturn &= @CRLF Next Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, False) EndIf FileWrite($hFileOpen, $sReturn) FileClose($hFileOpen) Return True EndFunc ;==>_GUICtrlListView_SaveTxt Function with an array: - It uses another function called >_GUICtrlListView_CreateArray() #include <Constants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_SaveTxtEx ; Description ...: Exports a listview to a txt file. ; Syntax ........: _GUICtrlListView_SaveTxtEx(Const Byref $aArray, $sFilePath[, $sDelimiter = '|']) ; Parameters ....: $aArray - [in/out and const] A 2-dimensional array returned by _GUICtrlListView_CreateArray. ; $sFilePath - Filepath to save the txt data string to. ; $sDelimiter - [optional] Delimiter to distinguish between columns. Default is |. ; Return values .: Success - True ; Failure - False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_SaveTxtEx(ByRef Const $aArray, $sFilePath, $sDelimiter = '|') If $sDelimiter = Default Then $sDelimiter = '|' EndIf Local Const $iColumnCount = $aArray[0][1] - 1 Local $sReturn = '' For $i = 1 To $aArray[0][0] For $j = 0 To $iColumnCount $sReturn &= $aArray[$i][$j] If $j < $iColumnCount Then $sReturn &= $sDelimiter EndIf Next $sReturn &= @CRLF Next Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, False) EndIf FileWrite($hFileOpen, $sReturn) FileClose($hFileOpen) Return True EndFunc ;==>_GUICtrlListView_SaveTxtEx Download the ZIP file to obtain all exporting UDFs as well as an example of usage. ListView Export.zip Other Examples for exporting ListView data are: >_GUICtrlListView_SaveCSV(), >_GUICtrlListView_SaveHTML() & >_GUICtrlListView_SaveXML()1 point
-
_SoundGetPos/Length inaccurate?
TheNorwegianUser reacted to Melba23 for a topic
TheNorwegianUser, Why are you not using the Sound.au3 function that is designed to tell you when a sound file has ended? The return from _SoundStatus will do what you want without the need to measure the elapsed time of the track itself. M231 point -
From the wiki, link is at the top of the page. http://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F1 point
-
lgvlgv, My RecFileListToArray UDF will do exactly what you want - but it does search the whole disk as I am unaware of any other way to look for a specific file. M231 point
-
Mouse goto highlighted text
olo reacted to JLogan3o13 for a topic
Wasting two weeks on trying to automate some stupid game? Who would do that? muttley1 point -
Hello Every One
Mobius reacted to Xenobiologist for a topic
Nice, and now you are a support case muttley1 point -
This improves the readability of not function. Parameters by default are unknown. For some functions just slows down work in a loop. Func _ArrayDisplay(Const ByRef $avArray, $sTitle = Default, $iItemLimit = Default, $iTranspose = Default, $sSeparator = Default, $sReplace = Default, $sHeader = Default) If (Not IsArray($avArray)) Or (Not UBound($avArray, 1)) Then Return SetError(1, 0, 0) ; Default values If $sTitle = Default Then $sTitle = "Array: ListView Display" If $iItemLimit = Default Then $iItemLimit = -1 If $iTranspose = Default Then $iTranspose = 0 If $sSeparator = Default Then $sSeparator = "" If $sReplace = Default Then $sReplace = "|" If $sHeader = Default Then $sHeader = ""1 point
-
I'm no expert on any of this so take this with that understanding. First, the 4 parameters are used in this function because GUIRegisterMsg sends up to 4 parameters to a function when one of the Windows messages are received/detected. The first one is the handle of the window that sent the message, the second is the message it sent, the third and fourth are Windows message specific and varies between the different messages. Then, it's creating a struct to handle the message pointer referenced by the lparam, the $tagNMHDR is a string defined elsewhere in the UDF, that tells the struct what to expect for values in each position. It splits those values off from the struct and puts them into variables in the lines below it. $GUI_RUNDEFMSG tells the function to return the Windows message information back to the script rather than discarding it and not notifying the window that the message was sent in the first place. From the help file:1 point
-
Putting a macro into a variable?
wisem2540 reacted to MouseSpotter for a topic
If you want to keep your original method - you could try the execute command $value="@hour" MsgBox(0,"Hour",Execute($value)) $value="@sec=10" do Sleep(0) until Execute($value)1 point -
ElseIf with OR comparison executing incorrectly
Tripredacus reacted to Jos for a topic
Either way... the OR logic is wrong. Should be: ElseIf $value = "Name2" OR $value = "Name5" Then Jos edit: like BrewManNH said.1 point -
ElseIf with OR comparison executing incorrectly
Tripredacus reacted to BrewManNH for a topic
Your mistake was that it should have been written like this: ElseIf $value = "Name2" OR $value = "Name5" Then The way you wrote it meant that it was comparing $value to the string "Name2" OR comparing the string "Name5" to a boolean value of true or false. Because "Name5" isn't an empty string, it is evaluated as True.1 point -
Taskbar for no GUI script
PoojaKrishna reacted to guinness for a topic
Okay. Then no need to create a new GUI and waste resources. Just use AutoIt's Hidden window. #include <GUIConstantsEx.au3> Example() Func Example() ; Display AutoIt's Hidden window. See AutoItWinGetTitle and AutoItWinSetTitle for more details. AutoItWinShow() ; Set the title of the AutoIt Hidden window. AutoItWinSetTitle('AutoIt Hidden Window') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example ; Display AutoIt's Hidden window. Returns the handle of the window. Func AutoItWinShow() Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden window. WinMove($hWnd, '', -9999, -9999, 0, 0) ; Move the AutoIt Hidden Window and re-size for a better view of the data that will be set. WinSetState($hWnd, '', @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it. Return $hWnd EndFunc ;==>AutoItWinShow1 point -
find a text and the text position?
phamdacloc reacted to Decipher for a topic
phamdacloc, Welcome to the AutoIt Forums. Tip #1 is don't revisit 6 year old topics, instead create a new one. I'll look into it for ya. *Edit - Here ya go Anonymous1 point -
True, but I presume those who would use the idea would know what they're doing.1 point
-
Not quite what one should be aiming at.. huh?? I think this one is a bit appropriate.. Global $needshelp=10, $assistance=0, $stop_being_a_lazy_ass=20 MsgBox(64,"Status","Help Needed: " & $needshelp*10 &" %" & @CRLF & "Tendency to be lazy: " & $stop_being_a_lazy_ass*5 &" %"&@CRLF & "Assistance given by forum members: " & $assistance*10 &" %") If $needshelp<$stop_being_a_lazy_ass And $stop_being_a_lazy_ass=20 Then MsgBox(16,"You don't deserve help!!","Get off your lazy ass and start working for a solution!!") $stop_being_a_lazy_ass-=5 EndIf MsgBox(64,"Status","Help Needed: " & $needshelp*10 &" %" & @CRLF & "Tendency to be lazy: " & $stop_being_a_lazy_ass*5 &" %"&@CRLF & "Assistance given by forum members: " & $assistance*10 &" %") If $needshelp<$stop_being_a_lazy_ass And $stop_being_a_lazy_ass=15 Then MsgBox(16,"Ok now you qualify for atleast some help","Show me your script") $stop_being_a_lazy_ass-=5 $assistance+=2 EndIf MsgBox(64,"Status","Help Needed: " & $needshelp*10 &" %" & @CRLF & "Tendency to be lazy: " & $stop_being_a_lazy_ass*5 &" %"&@CRLF & "Assistance given by forum members: " & $assistance*10 &" %") If $stop_being_a_lazy_ass=10 Then MsgBox(16,"I will help you!!","Make these changes in your script") $stop_being_a_lazy_ass-=5 $assistance+=5 $needshelp-=3 EndIf MsgBox(64,"Status","Help Needed: " & $needshelp*10 &" %" & @CRLF & "Tendency to be lazy: " & $stop_being_a_lazy_ass*5 &" %"&@CRLF & "Assistance given by forum members: " & $assistance*10 &" %") If $stop_being_a_lazy_ass=5 Then MsgBox(16,"Now you are almost there!!","Make these changes in your script!!") $stop_being_a_lazy_ass-=5 $assistance+=3 $needshelp-=3 EndIf MsgBox(64,"Status","Help Needed: " & $needshelp*10 &" %" & @CRLF & "Tendency to be lazy: " & $stop_being_a_lazy_ass*5 &" %"&@CRLF & "Assistance given by forum members: " & $assistance*10 &" %") If $stop_being_a_lazy_ass=0 Then MsgBox(64,"There you go!!","Done!! Script is ready") $stop_being_a_lazy_ass-=5 $assistance+=2 $needshelp-=2 EndIf MsgBox(4096,"Morale of the story","Help yourself and show an effort and only then expect help from others!!") I made my point, and didn't need a loop for it!!1 point