Leaderboard
Popular Content
Showing content with the highest reputation on 11/14/2013 in all areas
-
I personally like to make (large) headers in my code which makes it simpler for me to navigate quickly. There was the FigLet tool already, but it was not integrated into the editor. I modified it a little and present here my first try of example script. Features: [version 1.01] Settings via ini file Will ignore non-English characters and replace by user-defined User-definable comment style when inserting Auto-insert at cursor point in SciTE (thanks to Jon for help with this !) My idea of the tool is to bind it to a key, to very quickly be able to insert banners, already commented out. I would really appreaciate any comments on this. You are welcome to make / suggest additions + improvements. Edit: attached zip.au3. ;~ ####### ####### ;~ # # #### # ###### ##### # #### #### # ;~ # # # # # # # # # # # # # ;~ ##### # # # ##### # # # # # # # ;~ # # # ### # # # # # # # # # ;~ # # # # # # # # # # # # # ;~ # # #### ###### ###### # # #### #### ###### ;~ ;~ ####### # ### ####### ##### ;~ # #### ##### # # # # ##### #### # # # # ;~ # # # # # # # # # # # # # # # ;~ ##### # # # # # # # # # # # # # ##### ;~ # # # ##### ####### # # # # # # # # ;~ # # # # # # # # # # # # # # # # ;~ # #### # # # # #### # #### ### # ##### ;~ ;~ _ _ _ __ _____ __ ;~ | | | | (_) / | | _ |/ | ;~ | | | | ___ _ __ ___ _ ___ _ __ `| | | |/' |`| | ;~ | | | | / _ \| '__|/ __|| | / _ \ | '_ \ | | | /| | | | ;~ \ \_/ /| __/| | \__ \| || (_) || | | | _| |_ _ \ |_/ /_| |_ ;~ \___/ \___||_| |___/|_| \___/ |_| |_| \___/(_) \___/ \___/ ;~ #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Zip.au3> Global $gInputText, $gComboFont, $gEditSignature, $gCurrentFont = "", $gSelFont, $gCommentStyle, $gUnknownReplace Global $gFontData, $gFontMetaData[10], $gFontDir = @ScriptDir & "\fonts\" _Main() Exit Func _Main() ; Create and show GUI GUICreate("AutoFiglet", 810, 426, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) GUICtrlCreateLabel("Text line", 8, 8, 550, 16) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT)) $gInputText = GUICtrlCreateInput("", 8, 28, 550, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT)) $gEditSignature = GUICtrlCreateEdit("", 8, 56, 794, 320, BitOR($ES_AUTOVSCROLL, $WS_HSCROLL, $ES_WANTRETURN)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUICtrlSetFont(-1, 9, 400, 0, "Courier New") Local $btnGenerate = GUICtrlCreateButton("Generate", 680, 384, 122, 32, $BS_DEFPUSHBUTTON) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKHEIGHT, $GUI_DOCKWIDTH)) GUISetState(@SW_SHOW) ; setup selected font $gSelFont = IniRead(@ScriptDir & "\figlet.ini", "figlet", "font", "banner") ; does font exist ? No, set to "banner" If Not FileExists($gFontDir & "\" & $gSelFont & ".zip") Then $gSelFont = "banner" EndIf ; setup comment style $gCommentStyle = IniRead(@ScriptDir & "\figlet.ini", "figlet", "comment", ";" & @TAB) $gCommentStyle = StringReplace($gCommentStyle, "\t", @TAB) ; setup unknown replacement $gUnknownReplace = IniRead(@ScriptDir & "\figlet.ini", "figlet", "unknown", "space") $gUnknownReplace = StringReplace($gUnknownReplace, "space", " ") $gUnknownReplace = StringReplace($gUnknownReplace, "question", "?") $gUnknownReplace = StringReplace($gUnknownReplace, "none", "") ; initially load the font _LoadFont($gSelFont) ; WM_COMMAND will tell us when the text has changed GUIRegisterMsg($WM_COMMAND, "_WmCommand") Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnGenerate ;~ _SciTE_InsertText($figlet) $figlet = GUICtrlRead($gEditSignature) ; Comment out for AutoIT $figlet = StringRegExpReplace($figlet, "(?m)^.", $gCommentStyle) ; fix for insertion into SciTE ; thanks to Jos for help on this!! $figlet = StringReplace($figlet, @CRLF, "\r") _SciTE_InsertText($figlet) Exit EndSwitch WEnd ; Discard GUI GUIDelete() EndFunc ;==>_Main Func _WmCommand($hWndGUI, $msgID, $wParam, $lParam) If $lParam = GUICtrlGetHandle($gInputText) Then If _WinAPI_HiWord($wParam) = $EN_CHANGE Then ;~ _Display(GUICtrlRead($gInputText), GUICtrlRead($gComboFont)) _Display(GUICtrlRead($gInputText), $gCurrentFont) EndIf EndIf EndFunc ;==>_WmCommand Func _Display($sText, $sFontName) Local $i, $j, $sChar, $sOutput = "" _LoadFont($sFontName) For $i = 1 To $gFontMetaData[2] For $j = 1 To StringLen($sText) $sChar = StringMid($sText, $j, 1) ; need to handle English (figlet compatible) chars only... If StringRegExp($sChar, "(?i)[a-z0-9[:punct:]\s]") Then $sOutput &= _GetCharacter($sChar, $i) Else ; handle replacement with nothing... if stringlen($gUnknownReplace) >0 then $sOutput &= _GetCharacter($gUnknownReplace, $i) EndIf EndIf Next $sOutput &= @CRLF Next GUICtrlSetData($gEditSignature, $sOutput) EndFunc ;==>_Display Func _LoadFont($sFontName) If $sFontName = $gCurrentFont Then Return Local $aTemp, $sTemp, $nUBound, $sFileLocation = $gFontDir & $sFontName & ".flf", $fTemp = False ; Try and unzip it first FileCopy($sFileLocation, @TempDir & "\" & $sFontName & ".zip") _Zip_UnzipAll(@TempDir & "\" & $sFontName & ".zip", @TempDir) If @error = 0 Then ; It unzipped OK so let's flag the temporary file $fTemp = True $sFileLocation = @TempDir & "\" & $sFontName & ".flf" EndIf FileDelete(@TempDir & "\" & $sFontName & ".zip") ; Read in the figlet font in to out array _FileReadToArray($sFileLocation, $gFontData) $aTemp = StringSplit($gFontData[1], " ", 2) ; Split the first line at spaces $nUBound = UBound($aTemp) ; Remember how many parameters we have $sTemp = $aTemp[0] ; This contains the signature and the hard blank character $gFontMetaData[0] = StringLeft($sTemp, StringLen($sTemp) - 1) ; Signature $gFontMetaData[1] = StringRight($sTemp, 1) ; Hard blank $gFontMetaData[2] = Number($aTemp[1]) ; Height of each letter ;$gFontMetaData[3] = Number($aTemp[2]) ;$gFontMetaData[4] = Number($aTemp[3]) ;$gFontMetaData[5] = Number($aTemp[4]) $gFontMetaData[6] = Number($aTemp[5]) ;If ($nUBound > 6) Then $gFontMetaData[7] = Number($aTemp[6]) ;If ($nUBound > 7) Then $gFontMetaData[8] = Number($aTemp[7]) ;If ($nUBound > 8) Then $gFontMetaData[9] = Number($aTemp[8]) ;If ($gFontMetaData[0] <> "flf2a") Then Return SetError(1, 0, $sFontName & " is not a valid font") If $fTemp Then FileDelete($sFileLocation) $gCurrentFont = $sFontName EndFunc ;==>_LoadFont Func _GetCharacter($sChar, $nLine) Local $nStart = $gFontMetaData[6] + ((Asc($sChar) - 32) * $gFontMetaData[2]), $sTemp $sTemp = $gFontData[$nStart + $nLine + 1] $sTemp = StringReplace($sTemp, StringRight($sTemp, 1), "") $sTemp = StringReplace($sTemp, $gFontMetaData[1], " ") Return $sTemp EndFunc ;==>_GetCharacter ; ======================================================================================== Func _SciTE_InsertText($sString) Return _SciTE_Send_Command(0, WinGetHandle("DirectorExtension"), "insert:" & $sString) EndFunc ;==>_SciTE_InsertText Func _SciTE_Send_Command($hHandle, $hSciTE, $sString) Local $ilParam, $tData If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf $sString = ":" & Dec(StringTrimLeft($hHandle, 2)) & ":" & $sString ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sString = ' & $sString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $tData = DllStructCreate("char[" & StringLen($sString) + 1 & "]") ; wchar DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ptr;dword;ptr") ; ulong_ptr;dword;ptr DllStructSetData($ilParam, 1, 1) ; $ilParam, 1, 1 DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hSciTE, $WM_COPYDATA, $hHandle, DllStructGetPtr($ilParam)) Return Number(Not @error) EndFunc ;==>_SciTE_Send_Command A ini-file for settings: [figlet] ; name of font file without extension ; if not existing or not found, font is "banner" font=banner ; default style of commenting ; use \t for tab comment=;~\t ; value of unknown ; use space | question | none unknown=none Zip.au32 points
-
Solved! StringRegExpReplace Left 0 Padding: Solved!
LordBoling and one other reacted to corgano for a topic
would not this work? StringRegExpReplace($new_items[$i][0],"([1-9]{1,2})(0*)(\d{2,4})","$1-$3") changed the third one to d{2,4} because you want at least two digits? Also, http://gskinner.com/RegExr/. Save it, bookmark it, love it. It's like the SciTE of regex2 points -
Although serial ports are disappearing, they can still be useful. Here is a COMMs UDF. It provides an easy way to use serial ports without the restrictions and problems some methods have. USB to serial is ok, binary data is ok. This UDF requires my comMG.dll which can be in either the script folder or the Windows folder by default, or in the path specified using the function _CommSetDllPath. Note the following shortcomings: the dll link below is 32 bit so it will not work with a 64 bit apps, but there is a 64 bit version in my post around 25th March 2018 for people to try. The strings and character functions are all AnsiChar. Functions in the UDF are _CommVersion _CommListPorts _CommSetPort _CommPortConnection _CommClearOutputBuffer _CommClearInputBuffer _CommGetInputcount _CommGetOutputcount _CommSendString _CommGetString _CommGetLine _CommReadByte _CommReadChar _CommSendByte _CommSendBreak; not tested!!!!!!!!!! _CommCloseport _CommSwitch _CommReadByteArray _CommSendByteArray _CommsetTimeouts _CommSetXonXoffProperties _CommSetRTS (NB these will not work if Hardware handshaking is selected because _CommSetDTR then these lines are controlled by the data being sent.) _CommSetDllPath _CommGetLineStates -------------------------------------------------------------------------------------------------------------------------------- Go to Download Page For Commgv2 Download includes the dll and udf. Most recent changes 28th March 2014 - dll V2.83 Correct error setting 6 data bits as 7. 11th March 2014 dll V2.82 Allow data bits of 4 to 8 instead of only 7 and 8. 19th August 2013 dll v2.81 removes some unwanted eroor message popups. Might not remove popups for some Windows versions. 27th September 2012 Correct error closing port. New version of UDF if V2.90, new dll is commg.dll V2.79. Thanks to tfabris. 18th January 2012 Corrected typo in UDF V 2.87, and uploaded as V2.88 Increased max baud allowed by the dll from 200000 to 256000. New version now V2.78 17th January 2012 Modified thesleep addition to _CommGetLine so that reading data is not slowed down. 14th January 2012 Corrected _CommReadByte in UDF. Added sleep(20) to while loop in _CommGetLine to reduce CPU usage 20th December 2011 UDF version 2.86. - Changed function GetByte so it returned the error string given by the dll. Dll version 2.77 - removed an unwanted erro message dialogue from GetByte function. (Thanks funkey) 4th December 2011 New dll and example versions. Dll function SetPort corrected because it was not using the parameters passed for DTR and RTS. The example was setting flow control incorrectly: the settings for hardware handshaking and XON./XOFF were reversed. 25th August 2011 corrected function _CommClosePort. Example corrected for setting parity and flow 22nd December 2013 (thanks to MichaelXMike) mgrefcommg CommgExample.au31 point
-
Or at least have the decency to document what the value is representing.1 point
-
That is called a magic number and corresponds to this $LVM_SETCOLUMNWIDTH = ($LVM_FIRST + 30), $LVM_FIRST = 0x1000, so 0x1000 + 30 = 0x101E Which is why you shouldn't use hardcoded numbers like this in a script for public usage, as then no one knows what you're referring to. Use the constants that are there to help with this.1 point
-
,ad8888ba, 88 88 88 88 88 88 88 d8"' `"8b 88 88 88 "" 88 "" ,d 88 8' 88 88 88 88 88 88 8 88 ,adPPYYba, ,adPPYb,88 8b d8 ,adPPYba, 88 88 88 88 88 ,d8 ,adPPYba, 88 MM88MMM 88 8 88888 88 "" `Y8 a8" `Y88 `8b d8' a8" "8a 88 88 88 88 88 ,a8" a8P_____88 88 88 88 8, 88 88 ,adPPPPP88 8b 88 `8b d8' 8b d8 88 88 88 88 8888[ 8PP""""""" 88 88 "" Y8a. .a88 88 88, ,88 "8a, ,d88 `8b,d8' "8a, ,a8" "8a, ,a88 88 88 88`"Yba, "8b, ,aa 88 88, aa `"Y88888P" 88 `"8bbdP"Y8 `"8bbdP"Y8 Y88' `"YbbdP"' `"YbbdP'Y8 88 88 88 `Y8a `"Ybbd8"' 88 "Y888 88 d8' d8'1 point
-
DxMxS, The regex Melba posted meant "find all matches" , the regexreplace I wrote meant "fire all but matches" , in both cases the approach is similar Maybe what you want is possible using regex, but this looks like a headache to come while the simplest way is usually the best one In this case Melba's solution does the job perfectly #include <Array.au3> $array = StringRegExp($text, 'FWL\d*', 3) $new_array = _ArrayUnique($array) Edit Nonetheless ... #include <GUIConstantsEx.au3> $sText = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" & @CRLF & _ "FWL12345" & @CRLF & _ "FWL9875632" & @CRLF & _ "yyyyyyyyyyyyyyyyyyyyyyyyyyyy" & @CRLF & _ "FWL12345" & @CRLF & _ "zzzzzzzzzzzzzzzzzzzzzzzzzzzz" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "FWL45678965" & @CRLF & _ "FWL12345" & @CRLF & _ "FWL985612565" & @CRLF & _ "bbbbbbbbbbbbbbbbbbbbbbbbb" $hGUI = GUICreate("Test", 500, 500) $cEdit = GUICtrlCreateEdit($sText, 10, 10, 480, 400) $cButton = GUICtrlCreateButton("Filter", 10, 450, 80, 30) GUICtrlSetState($cButton, $GUI_FOCUS) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Filter() EndSwitch WEnd Func Filter() $ret = StringStripWS(StringRegExpReplace(GuiCtrlRead($cEdit), '(?s).*?((FWL\d*)(?!.*\2.*)|$)', '$2' & @crlf), 3) GuiCtrlSetData($cEdit, $ret) EndFunc1 point
-
I'm not sure about doing it through the registry, but you can set it through powercfg commands. The pre-configured schemes have the following GUIDs: Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced) Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c (High performance) Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a (Power saver) I'll use the Balanced scheme for my examples, but you would use the GUID provided by: powercfg -GETACTIVESCHEME You can find the GUIDs for subgroups and power settings as well as the index values for each power setting by running a query command with your scheme GUID: powercfg -Q 381b4222-f694-41f0-9685-ff5bb260df2e Looking through the output, you will discover that the subgroup GUID you want is: Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid) and the power setting: Power Setting GUID: 5ca83367-6e45-459f-a27b-476b1d01c936 (Lid close action) with index options: Possible Setting Index: 000 Possible Setting Friendly Name: Do nothing Possible Setting Index: 001 Possible Setting Friendly Name: Sleep Possible Setting Index: 002 Possible Setting Friendly Name: Hibernate Possible Setting Index: 003 Possible Setting Friendly Name: Shut down So in order to configure your system to Shut down when the lid is closed, you would run: powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3 powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3 AC for the "Plugged In" action and DC for the "On Battery" action.1 point
-
SMF - The fastest duplicate files finder... [Updated 2024-Oct-20]
ffibestsolution reacted to Ascend4nt for a topic
works now Nice job! Very professional looking and feature-rich tool1 point -
prevent multiple runs, is that possible?
Starstar reacted to Squirrely1 for a topic
To soulhealer: MHz told you correctly in the first place, because I still haven't read FAQ #14. The last time I read that page was in the production version where there were only 10 FAQs. If you use the production version of AutoIt, then use this: ; For use with the production version of AutoIt (basic method suggested by helpfile FAQ #14) ; Place this near the top of your script $g_szVersion = "My Somewhat Unique Window Title" If WinExists($g_szVersion) Then ; An instance is already running! Exit EndIf AutoItWinSetTitle($g_szVersion) or this: ;Method that looks like it would work with the production version of AutoIt: If UBound(ProcessList(@ScriptName)) > 2 Then ;MsgBox(262208, "* NOTE * ", "Welcome to AutoIt 1-2-3 was already running ", 5) Exit EndIf If you use the beta version of AutoIt, get the benefit of Valik's hard work, and use this: ; For use with the latest AutoIt beta, put this near the beginning of your script: #include <Misc.au3> If Singleton("[InsertHereAnyUniqueString; ItServesAsAnInstanceIdentifier (or semaphore)]", 1) == 0 Then ; An instance is already running! Exit EndIf Forum Reference To whom it may concern... Quotes of Valik on the subject: Famous Valik quotes: Famous Responses to Valik: New Response to Valik: I am put back in my place, sir. While you are the elder aboard, I am merely the jetsam. My method could indeed fail, but I can see only one way for it to fail when the program is run locally, and that is if the user changes the name of the executable. Oh, but I am yet the flotsam--don't get me wrong. I seek your higher wisdom, for, as you can obviously see, I am but a 7-year-old black-and-white starlet left over from the late 1950s, and I felt truly compelled to follow your every instruction up to this point, including being shot repeatedly. And I am glad you had me search the forums, because not only did I end up finding the correct syntax for _Singleton() so I could use that command, I also in the process, happened upon the method for deleting the currently running executable file. Thanks Valik, and pardon me, MHz: mea culpa executed this Sunday morning, the twenty-third day of July, in the year of Our Lord Jesus Christ twenty-hundreds and six.1 point