Leaderboard
Popular Content
Showing content with the highest reputation on 05/18/2019 in all areas
-
Just delete the txt file?
Earthshine and 2 others reacted to mikell for a topic
$folder = FileSelectFolder("Select Folder", @ScriptDir) If $folder = "" Or @error Then Exit FileDelete($folder & "\*.txt")3 points -
I dont make scripts for people who dont properly sanitize their input, its gross2 points
-
Help me
FrancescoDiMuro and one other reacted to Jos for a topic
Seriously? I like to be taken serious so we are done with your questions here, and don't start this in a new thread again. *cick*2 points -
Search for text within a string after specific text
Earthshine reacted to Exit for a topic
@iamtheky Not foolproof, see aditional blank In customer Global $A = "Customer Name: John Smith, Address: 1234 Main Street, Chicago, IL, Customer Rec#: 123457, PHone Number#: 555-555-1212" msgbox(0, '' , StringLeft((stringmid($A , StringInStr($A , "Customer Rec#: ") + StringLen("Customer Rec#: ") - 1)) , (StringInStr(stringmid($A , StringInStr($A , "Customer Rec#: ") + StringLen("Customer Rec#: ") - 1) , ",") - 1)),2) ;~ Not foolproof, see aditional blank In customer ---------------------------------v Global $A = "Customer Name: John Smith, Address: 1234 Main Street, Chicago, IL, Cus tomer Rec#: 123457, PHone Number#: 555-555-1212" msgbox(0, '' , StringLeft((stringmid($A , StringInStr($A , "Customer Rec#: ") + StringLen("Customer Rec#: ") - 1)) , (StringInStr(stringmid($A , StringInStr($A , "Customer Rec#: ") + StringLen("Customer Rec#: ") - 1) , ",") - 1)))1 point -
I need some help!
theonemc reacted to abberration for a topic
one way is to make part of your script into a function and call that function when you push the button.1 point -
Multi-Tasking UDF
Network_Guy reacted to Dustbeen43 for a topic
For people who wants to haver another example of the utility of this lib, here is my script : "GIJOE". I'am launching 2 threads and both threads has its own procedure and they are communicating with shared variables. The logic here is that the Thread 1 (Charly) is covering the back of the Thread 2 (Tango). If T1 is in combat then he changed his variable to say that he is in combat (so T2 is paused during the fight and he is resumed after the end of the combat). T1 has 6 HP ( while $loop < 7 but you can change it ) so if thread 2 has not finished before the secund fight (one fight every 3 rounds) then the thread 1 wil stopped. In that case T2 has to stopped because T1 has stopped. The Thead 2 (Tango) is the twin of the first one. He's goal is to arrive in a destination which is at a distance of 9 ( while $loop < 10 but you can change it ) so if the T2 arrives before the thread 1 then T2 stops too. With the original script, T1 will die before T2 but you can change the condition of both while to see the 2 different case. NB : each script has it's own logfile so you can see actions both thread are doing. NB2: "MultiTasking.au3" and its dependancies must be in the same directory of the file. I want to thanks Network_guy for this lib and trancexx wich provide parts of this libs too. GIJOE.au31 point -
$file = FileSelectFolder("Select Folder", @ScriptDir) If $file = "" Or @error Then Exit $FileSearch = FileFindFirstFile($file & "\*.txt") If $FileSearch <> -1 Then While 1 $FileFind = FileFindNextFile($FileSearch) If @error Then ExitLoop FileDelete($file & "\" & $FileFind) Sleep(500) FileClose($FileSearch) WEnd EndIf1 point
-
Successive empty captures in the resulting array are there because there is a difference between Perl regex and legacy PCRE1 regex (which current AutoIt implements). PCRE2 (is 4 year old already) now conforms to Perl with respect of unwanted empty captures but it isn't the version AutoIt uses. Yet you can overcome this behavior difference by using the (?| ) construct: Local $s = "artist=MyArtist&title=MySong&album=TheBestOf&year=2019&type=Music" Local $r = StringRegExp($s, "(?|(?:artist=([^&]*))|(?:title=([^&]*))|(?:album=([^&]*))|(?:year=([^&]*))|(?:type=([^&]*)))", 3) _ArrayDisplay($r) But that doesn't solve the issue of unordered, extra or missing elements. To do that you need another idea: Local $aData = [ _ "title=MySong&album=TheBestOf&year=2019&artist=MyArtist&type=Music", _ "comment=this is pure junk&title=MySong&year=2019&artist=MyArtist&album=TheBestOf&type=Music", _ "title=MySong&year=2019&comment=excellent title&artist=MyArtist&album=TheBestOf" _ ] Local Static $aKeys = ["artist", "album", "year", "title", "type", "comment"] Local $d = ObjCreate("Scripting.Dictionary"), $dummy For $s In $aData $dummy = Execute(StringRegExpReplace($s, "(\w+)=([^&]*)&?", "$d.Add(""$1"", ""$2"") & ") & '""') For $k In $aKeys ConsoleWrite($k & " -> " & $d.Item($k) & @LF) Next ConsoleWrite(@CRLF) $d.RemoveAll Next This way you can add as many potential elements and pick them in fixed order.1 point
-
I wanted to create a HTML entity replacer. I solved it with a local static and an if-clause: Func HTMLDecode(ByRef $sHTML) $aEntities = StringRegExp($sHTML, '&(?>[A-z]+|#\d{2,4});', 3) ;_ArrayDisplay($aEntities,'$aEntities') ;CW('UBound($aEntities) ' & UBound($aEntities) & ' ' & IsArray($aEntities)) If IsArray($aEntities) = False Then Return ; nothing to replace... Local $mDistictEntities[] For $i = 0 To UBound($aEntities) - 1 $mDistictEntities[$aEntities[$i]] += 1 Next ;_ArrayDisplay(MapKeys($mDistictEntities),'MapKeys($mDistictEntities)') ;CW(MapToString($mDistictEntities)) ;FileWrite('HTML Entities.txt', MapToString($mDistictEntities) & @CRLF & @CRLF) Local Static $mHTMLEntities[] ; https://de.wikipedia.org/wiki/Hilfe:Sonderzeichenreferenz If UBound($mHTMLEntities) = 0 Then $mHTMLEntities['"'] = '"' $mHTMLEntities['"'] = '"' $mHTMLEntities['&'] = '&' ; 38 $mHTMLEntities['''] = "'" $mHTMLEntities['>'] = '>' ; 62 $mHTMLEntities[' '] = ' ' ; 160 $mHTMLEntities[' '] = ' ' ; 160 $mHTMLEntities['©'] = '©' $mHTMLEntities['©'] = '©' ; 169 $mHTMLEntities['«'] = '«' ; 171 Guillemet linksweisend („französisches Anführungszeichen“) $mHTMLEntities['«'] = '«' ; 171 Guillemet linksweisend („französisches Anführungszeichen“) $mHTMLEntities['­'] = '' ; 173 Trennmöglichkeit, weiches Trennzeichen (soft hyphen) $mHTMLEntities['»'] = '»' ; 187 Guillemet rechtsweisend („französisches Anführungszeichen“) $mHTMLEntities['»'] = '»' ; 187 Guillemet rechtsweisend („französisches Anführungszeichen“) $mHTMLEntities['Á'] = 'Á' ; 193 $mHTMLEntities['É'] = 'É' ; 201 $mHTMLEntities['é'] = 'é' $mHTMLEntities['Ä'] = 'Ä' $mHTMLEntities['Ä'] = 'Ä' ; 196 $mHTMLEntities['Ö'] = 'Ö' $mHTMLEntities['Ö'] = 'Ö' ; 214 $mHTMLEntities['Ü'] = 'Ü' $mHTMLEntities['Ü'] = 'Ü' ; 220 $mHTMLEntities['ß'] = 'ß' $mHTMLEntities['ß'] = 'ß' $mHTMLEntities['ä'] = 'ä' $mHTMLEntities['ä'] = 'ä' $mHTMLEntities['è'] = 'è' $mHTMLEntities['ö'] = 'ö' $mHTMLEntities['ö'] = 'ö' $mHTMLEntities['ü'] = 'ü' $mHTMLEntities['ü'] = 'ü' $mHTMLEntities['ı'] = 'ı' ; Turksprachen, ähnlich 'i' $mHTMLEntities['ş'] = 'ş' ; Turksprachen, Deutsch: sch $mHTMLEntities['̈'] = '̈' ; Kombinierendes Trema: macht aus normalen Buchstaben Umlaute $mHTMLEntities[' '] = ' ' ; schmales Leerzeichen $mHTMLEntities[' '] = ' ' ; 8201 schmales Leerzeichen $mHTMLEntities['​'] = '' ; breitenloses Leerzeichen (Trennmöglichkeit) $mHTMLEntities['–'] = '–' ; 8211 Halbgeviertstrich (Gedankenstrich) $mHTMLEntities['–'] = '–' ; 8211 Halbgeviertstrich (Gedankenstrich) $mHTMLEntities['‘'] = '‘' ; einfaches Anführungszeichen (englisch: öffnend, deutsch: schließend) $mHTMLEntities['’'] = '’' ; einfaches Anführungszeichen schließend (englisch); typographisch korrekter Apostroph $mHTMLEntities['‚'] = '‚' ; einfaches Anführungszeichen unten (deutsch öffnend) $mHTMLEntities['“'] = '“' ; 8220 $mHTMLEntities['„'] = '„' ; 8222 ;
 ??? $mHTMLEntities['€'] = '€' ; 8364 $mHTMLEntities['€'] = '€' ; 8364 $mHTMLEntities['★'] = '★' ; Schwarzer Stern EndIf For $vKey In MapKeys($mDistictEntities) If MapExists($mHTMLEntities, $vKey) = False Then ClipPut($vKey) MsgBox(0, 'HTML Entity Decode missing!', $vKey) EndIf ;CW($vKey& ' - ' & $mHTMLEntities[$vKey]) $sHTML = StringReplace($sHTML, $vKey, $mHTMLEntities[$vKey], 0, 1) Next EndFunc ;==>HTMLDecode1 point
-
If anyone has difficulties visualizing maps, my Map UDF has a handy _Map_Display function which displays the contents of a map in a neat GUI1 point
-
How to set the input border color?
Skysnake reacted to argumentum for a topic
#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cLabel = GUICtrlCreateLabel("", 9, 9, 202, 22) GUICtrlSetState($cLabel, $GUI_DISABLE) GUICtrlSetBkColor($cLabel, 0xFF0000) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20, -1, 0) ; <------ GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd1 point -
AutoIt Snippets
RestrictedUser reacted to guinness for a topic
ConsoleWrite('CPU Name: ' & _GetCPUName() & @CRLF) ; Version: 1.00. AutoIt: V3.3.8.1 ; Retrieve the name of the CPU. Func _GetCPUName() Local $oWMIService = ObjGet('winmgmts:{impersonationLevel = impersonate}!.rootcimv2') Local $oColFiles = $oWMIService.ExecQuery('Select * From Win32_Processor') If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return StringStripWS($oObjectFile.Name, 7) Next EndIf Return SetError(1, 0, '') EndFunc ;==>_GetCPUName1 point