Leaderboard
Popular Content
Showing content with the highest reputation on 03/24/2018 in all areas
-
cDebug.au3 includes four main debugging UDFs: _GuiDebug(), _ConsDebug(), _ClipDebug() and _FormatValsForDebug(). They all dump the values of all AutoIt subtypes and expressions, in a structured manner, including nested arrays and slices of them, and even DLL structs and maps. It is an alternative to a graphical debugger, offering GUI output. The format for calling the UDFs has been designed to make coding a call as convenient and fast as possible, minimizing coding effort and the chances of errors: the $name argument is often the same as the variables arguments, enclosed in quote marks. For DLL structures, if you specify a tag, cDebug checks for differences between it and what it detects. If you only specify a structure variable, it can report the structure it detects, with the values of elements. It does much more than MsgBox(), ConsoleWrite() and _ArrayDisplay(), in a definitely user-friendly manner, and does its best to avoid hiding your code in SciTE. It is fully documented. During development of new features, the current version is used to debug the upcoming version, so there is much testing. These UDFs have been in regular use for some years. Suggestions and bug reports are most welcome. Get the latest version in Example Scripts #AutoIt3Wrapper_Version=B ; beta 3.3.15.0 or greater is mandatory for cDebug.au3, not for cDebug no maps.au3 #include "cDebug.au3" Local $seasons[] $seasons.summer = 'May to September' $seasons.spring = 'April' $seasons.fall = 'October to November' $seasons.winter = 'December to March' Local $aCats[3][3] = [['jack','black',3],['suki','grey',4],[$seasons,'','']] Local $i = 1 Local $tStruct = DllStructCreate('uint') DllStructSetData($tStruct,1,2018) _GuiDebug('At line '&@ScriptLineNumber,'$cats,jack is,$cats[..][$i],$i,hex,structure{uint}', _ $aCats,$aCats[0][2],$aCats,$i,Hex(-$i),$tstruct) reports1 point
-
Multi OR
Miliardsto reacted to Bilgus for a topic
that should be an AND if you want OR it needs to be ;And if $col <> $Color[0] AND $col <> $Color[1] Then ;Or if Not ($col = $Color[0] OR $col = $Color[1]) Then1 point -
cDebug, an alternative to a graphical debugger
Earthshine reacted to c.haslam for a topic
Thank you for appreciating my motivation for creating cDebug.1 point -
You want to change the button of your gui, you have to look at the code to create the gui : GUICreate... and especially options. Look at style option...1 point
-
Thank you for the hint. So hier is my sample script: #NoTrayIcon ;============================================================================================================ ;Programm Options ;============================================================================================================ Opt("MustDeclareVars", 1) ;Variables must be pre-declared. Opt("TrayMenuMode", 3) ;The default tray menu items will not be shown, items are not checked when selected. ;============================================================================================================ ;Libraries Inclusions ;============================================================================================================ #include <ColorConstants.au3> #include <TrayConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GuiButton.au3> #include <StaticConstants.au3> ;============================================================================================================ ;Global Vars ;============================================================================================================ Global $MainGUIWiHd Global $MGUIGetMsg0 Global $TrayMenMain Global $TrayMenExit Main() Func Main() ;------------------------------------------------------------------------------------------------------------ ;Create Main Window ;------------------------------------------------------------------------------------------------------------ $MainGUIWiHd = GUICreate("Sample", 520, 520, 50, 50, BitOR($WS_SYSMENU, $WS_CAPTION, $DS_SETFOREGROUND)) GUISetFont (8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $MainGUIWiHd, $CLEARTYPE_QUALITY) GUISetBkColor(0xDDDDDD, $MainGUIWiHd) GUISetState(@SW_SHOW, $MainGUIWiHd) WinWaitActive($MainGUIWiHd) ;============================================================================================================ ;Create Traymenu ;============================================================================================================ ;Create a Traymenu. $TrayMenMain = TrayCreateItem("Sample", -1, 0) ;Create a Separator line. TrayCreateItem("", -1, -1) ;Create a Menuitem. $TrayMenExit = TrayCreateItem("Exit", -1, -1) ;Show the Traymenu. TraySetState($TRAY_ICONSTATE_SHOW) ;#comments-start ;------------------------------------------------------------------------------------------------------------ ;Sample ;------------------------------------------------------------------------------------------------------------ Local $IconButtons[0] ;Array to manage Buttons Local $IconBLabels[0] ;Array to manage Buttons Local $ButtonPosLe = 10 ;Inserting Position X Local $ButtonPosTo = 10 ;Inserting Position Y Local $ButtonCount Local $MessageText Local $MessageTemp Local $IcPosOffset = 0 for $ButtonCount = 1 to 70 ;Jump to higher position after 60 Icons if $ButtonCount > 60 then $IcPosOffset = 265 _ArrayAdd($IconButtons, GUICtrlCreateButton("", $ButtonPosLe, $ButtonPosTo, 45, 45, $BS_ICON)) _ArrayAdd($IconBLabels, GUICtrlCreateLabel( -1 * ($ButtonCount + $IcPosOffset), $ButtonPosLe, $ButtonPosTo + 45, 45, 15)) GUICtrlSetStyle($IconBLabels[$ButtonCount - 1], BitOR($SS_CENTER, $SS_CENTERIMAGE)) $ButtonPosLe = $ButtonPosLe + 50 If Mod($ButtonCount, 10) = 0 Then $ButtonPosTo = $ButtonPosTo + 70 $ButtonPosLe = 10 EndIf ;retrieving Icons by negative ordinal position ;***************************************************************************************** $MessageTemp = GUICtrlSetImage($IconButtons[$ButtonCount - 1], "shell32.dll", -1 * ($ButtonCount + $IcPosOffset) , 1) ;***************************************************************************************** if $ButtonCount + $IcPosOffset = 1 or _ $ButtonCount + $IcPosOffset = 50 or _ $ButtonCount + $IcPosOffset = 51 or _ $ButtonCount + $IcPosOffset = 52 or _ $ButtonCount + $IcPosOffset = 53 or _ $ButtonCount + $IcPosOffset = 328 Then $MessageText = "Position: " & $ButtonCount + $IcPosOffset & " (of shell32.dll containing 327 Icons)" & @CRLF & @CRLF $MessageText = $MessageText & "Current GUICtrlSetImage return value is: " & $MessageTemp & @CRLF & @CRLF if $ButtonCount + $IcPosOffset <> 328 Then $MessageText = $MessageText & "But no Icon is retrieved... ." Else $MessageText = $MessageText & "As expected cose there are only 327 Icons... ." EndIf MsgBox($MB_SYSTEMMODAL, "Info", $MessageText, 0, $MainGUIWiHd) GUICtrlSetBkColor ($IconBLabels[$ButtonCount - 1], $COLOR_RED) EndIf If $ButtonCount + $IcPosOffset > 327 Then GUICtrlSetBkColor ($IconBLabels[$ButtonCount - 1], $COLOR_LIME) Next ;***************************************************************************************** $MessageText = "Retrieving by negative ordinal position, the first position fails." & @CRLF & @CRLF $MessageText = $MessageText & "Position 50 to 53 are also there but without Icon." & @CRLF & @CRLF $MessageText = $MessageText & "Starting from position 328 GUICtrlSetImage returns 0 (no more Icons)." & @CRLF & @CRLF ;***************************************************************************************** MsgBox($MB_SYSTEMMODAL,"Info", $MessageText, 0,$MainGUIWiHd) ;***************************************************************************************** $MessageText = "Trying with positive values, retrieving of position 1 works." & @CRLF & @CRLF $MessageText = $MessageText & "But 50 to 53 are stil without Icon... ." & @CRLF & @CRLF $MessageText = $MessageText & "This behavior seems inconsistent to me, considering that the function" & @CRLF $MessageText = $MessageText & "GUICtrlCreateICON is able to retrieve the first Icon by using -1... ." & @CRLF & @CRLF $MessageText = $MessageText & "Maybe is -1 a reserved value to the function GUICtrlSetIMAGE?" & @CRLF $MessageText = $MessageText & "Or is it a bug?" & @CRLF ;***************************************************************************************** MsgBox($MB_SYSTEMMODAL,"Info", $MessageText, 0,$MainGUIWiHd) $MessageTemp = GUICtrlSetImage($IconButtons[65], "shell32.dll", 1, 1) GUICtrlSetData($IconBLabels[65], 1) GUICtrlSetBkColor ($IconBLabels[65], $COLOR_YELLOW) $MessageTemp = GUICtrlSetImage($IconButtons[66], "shell32.dll", 50, 1) GUICtrlSetData($IconBLabels[66], 50) GUICtrlSetBkColor ($IconBLabels[66], $COLOR_YELLOW) $MessageTemp = GUICtrlSetImage($IconButtons[67], "shell32.dll", 51, 1) GUICtrlSetData($IconBLabels[67], 51) GUICtrlSetBkColor ($IconBLabels[67], $COLOR_YELLOW) $MessageTemp = GUICtrlSetImage($IconButtons[68], "shell32.dll", 52, 1) GUICtrlSetData($IconBLabels[68], 52) GUICtrlSetBkColor ($IconBLabels[68], $COLOR_YELLOW) $MessageTemp = GUICtrlSetImage($IconButtons[69], "shell32.dll", 53, 1) GUICtrlSetData($IconBLabels[69], 53) GUICtrlSetBkColor ($IconBLabels[69], $COLOR_YELLOW) ;============================================================================================================ ;GUI Loop ;============================================================================================================ While True ;------------------------------------------------------------------------------------------------------------ ;Get GUI-Messages ;------------------------------------------------------------------------------------------------------------ $MGUIGetMsg0 = GUIGetMsg() if $MGUIGetMsg0 = $GUI_EVENT_CLOSE Then ExitLoop ;------------------------------------------------------------------------------------------------------------ ;Get Traymenu Messages ;------------------------------------------------------------------------------------------------------------ Switch TrayGetMsg() Case $TrayMenExit ;Exit. ExitLoop EndSwitch ;------------------------------------------------------------------------------------------------------------ WEnd EndFunc Hope it works on your system... .1 point
-
Needed a way to store global temporary & permanent information and came up with this. This is inspired by NodeJS's store and store2 packages, as well as W3 specs' localStorage and sessionStorage, offering multiple ways of usage. This is not related to any browser's storage, nor will allow you to access or modify browsers storage - although this is possible and not a hard task, this is not what this UDF is intended to do. This UDF offers functions for temporary storage (that gets cleaned up once the application is shutdown) that is kept on memory using ScriptingDictionary, as well as for permanent storage, that is saved on the harddisk as an encrypted file. sessionStorage (temporary storage) It's useful to keep application state and temporary settings accessible by any part of your script (although it could also be done with a global variable, I still prefer this method). You have multiple ways, at your choice, to: ; add or modify a key sessionStorage("foo", "bar") store("foo", "bar") sessionStorage_set("foo", "bar") sessionStorage_setItem("foo", "bar") ; read a key (returns false if key does not exist) $read = sessionStorage("foo") $read = store("foo") $read = sessionStorage_get("foo") $read = sessionStorage_getItem("foo") ; delete a key sessionStorage_remove("foo") ; delete all keys sessionStorage_clear() sessionStorage_clearAll() localStorage (permanent storage) It's useful to store user-defined settings. ; initialize ; this is optional, but allows you to control ; how things are going to be saved localStorage_startup([file where you want the settings to be saved], [crypt password]) ; by default, if not supplied, if supplied the "Default" keyword (or if you dont initialize), ; the file will be a random-named file (based on @ScriptFullPath) at user's %APPDATA% ; and the password will also be based on @ScriptFullPath ; you can set only the crypt password if you want: ; localStorage_startup(Default, "mypassword") ; the usage is the same as sessionStorage ; add or modify a key localStorage("foo", "bar") store2("foo", "bar") ; notice the '2' localStorage_set("foo", "bar") localStorage_setItem("foo", "bar") ; read a key (returns false if key does not exist) $read = localStorage("foo") $read = store2("foo") $read = localStorage_get("foo") $read = localStorage_getItem("foo") ; delete a key localStorage_remove("foo") ; delete all keys localStorage_clear() localStorage_clearAll() Download1 point
-
Oh yes, I know there's much more than what I examplified. I simply followed Chimp restricted spec, simply forgot to make the numeric part optional, a gross overview. It's been many blue moons that I've typed ANSI escapes by hart. Should do what you asked for: Local $s = "Hello, " & Chr(27) & "[ 40;31mThis is red on black " & _ Chr(27) & "[ 47;32m And this is green on white" & _ Chr(27) & "[ 47 ; 32 m And this is also green on white (more spaces)" & _ Chr(27) & "[1234567890123456798Kvftio this matches the definition, albeit probably invalid ANSI escape" & _ Chr(27) & "[ 47;32 !!!! this is not an ANSI sequence" & _ Chr(27) & "[ z but this one is OK and final." Local $aRes = StringRegExp($s, "(?x)" & _ "(?(DEFINE) (?<ANSI_Escape> \[ (?:\s*\d*\s*;?)* [[:alpha:]]) )" & _ "(?| \x1B (?&ANSI_Escape) | (?:[^\x1B] (?!(?&ANSI_Escape)))+ )", 3) _ArrayDisplay($aRes, "Mixed results") Local $sClean = StringRegExpReplace($s, "(?x) (\x1B \[ (?:\s*\d*\s*;?)* [[:alpha:]])", "") MsgBox(0, "Pure text", $sClean)1 point
-
cDebug, an alternative to a graphical debugger
Earthshine reacted to Jefrey for a topic
Thank you! I've always tried to imagine a way to create a whoops-like error reporting system and a var_dump/print_r-like debugging helper for AU3 that could be easier than ConsoleWritting everything (and that does not only support arrays, as _ArrayDisplay, although it already helps a lot), and it looks like you could accomplish much of what I've thought. Going to use it now!1 point -
Don't know if that's GIGO below but I believe it fits the specs: Local $s = "Hello, " & Chr(27) & "[ 40;31mThis is red on black " & _ Chr(27) & "[ 47;32m And this is green on white" & _ Chr(27) & "[ 47 ; 32 m And this is also green on white (more spaces)" & _ Chr(27) & "[1234567890123456798Kvftio this matches the definition, albeit probably invalid ANSI escape" & _ Chr(27) & "[ 47;32 !!!! this is not an ANSI sequence" Local $aRes = StringRegExp($s, "(?x)" & _ "(?(DEFINE) (?<ANSI_Escape> \[\s*\d+\s* (?:;\s*\d+\s*)* [[:alpha:]]) )" & _ "(?| \x1B (?&ANSI_Escape) | (?:[^\x1B] (?!(?&ANSI_Escape)))+ )", 3) _ArrayDisplay($aRes, "Mixed results") Local $sClean = StringRegExpReplace($s, "(?x) (\x1B \[\s*\d+\s* (?:;\s*\d+\s*)* [[:alpha:]])", "") MsgBox(0, "Pure text", $sClean) The advantage of using DEFINE in such regexp is that you can very explicitely specify what's what and give it a name, using a construct equivalent to a procedural programming language subroutine. Using (?x) allows unsignificant whitespaces in the regexp to make it easier to read/dissect/understand.1 point
-
One of th ebiggest reasons I stopped using them was the code bloat that most produce. There are a lot of options to minimize that, but after a while it's just easier to throw a GUI together than trying to edit the control functions you don't need.1 point
-
TSP art generator
jaberwacky reacted to RTFC for a topic
I'm not surprised. Thanks for the reference; unfortunately, the website appears to be down at the moment; I'll try again later. It's funny though; the longer I look at these patterns, the more I'm reminded of brains; possibly not a coincidence that TSP optimises for shortest path and neuronal connections form a small-world network. Food for thought...1 point