Leaderboard
Popular Content
Showing content with the highest reputation on 05/05/2015 in all areas
-
​Exactly. Your argument is exactly a reflection of my thoughts. EDIT: It looks as if the character encoding has changed inside the file content. So removing the portion of the file, thereby changing its character encoding. btw. I'm still working on it to catch this imp.1 point
-
It works too, the closing brace used as 'delimiter' after the lazy star makes the final non-capturing group useless BTW the simplest could be $aQuestions = StringRegExp($str, '"q[^}]+\}', 3)You're right, the } doesn't need to be escaped but I have this habit ... The negated class is better than .*? because it avoids backtracking (http://www.regular-expressions.info/repeat.html)1 point
-
In your expression the ending .* matches the entire string You need to get "q\d": then the following braces with their content : \{ [^}]+ \} #include <Array.au3> $str = '{"q1":{"a2":[0,1],"a5":[0,0],"a3":[0,1],"a4":[0,0],"a1":[1,0]},"q2":{"a1":[1,1],"a2":[0,1]},"q3":{"a2":[1,0],"a4":[0,0],"a5":[0,0],"a3":[0,0],"a1":[0,1]},"q4":{"a2":[1,1],"a4":[0,1],"a1":[0,0],"a5":[0,1],"a3":0,0]},"q5":{"a1":[1,1],"a5":[0,1],"a4":[0,0],"a3":[0,0],"a2":[0,0]},"q6":{"a1":[1,1],"a4":[0,1],"a2":[0,1],"a3":[0,1]},"q7":{"a5":[1,0],"a3":[0,1],"a2":[0,1],"a1":[0,0],"a4":[0,1]},"q8":{"a3":[1,1],"a4":0,1],"a2":[0,1],"a1":[0,1]},"q9":{"a1":[1,0],"a2":[0,0]}}}}' $aQuestions = StringRegExp($str, '"q\d+":\{[^}]+\}', 3) _ArrayDisplay($aQuestions)1 point
-
Well, I love AutoIt 3 - yet when a Install new release, I just go through period of frustration. Code that worked yesterday, does not work today - UDF function ABC was discontinued - changed, deleted, replaced with .?. something else, some other function... Which one? How do I find out? New release notes are not very detailed, and the Googling doesn't always work... Would it be too difficult to publish somewhere a list of OLD functions and the matching NEW ones, intended to replace them? Or leave the old functions in the new UDF include file, marked as "Obsolete - do not used in new development"? Or even better, report them during Syntax Check as "Obsolete, replace with XYZ" ? Or at least change the Help file, so that the F1 (Help) on the old function ABC indicates that it is obsolete, and that new replacement is XYZ, and perhaps even indicate changes needed to apply to the old code when replacing the old function with the new one? I think it would make life of many users much easier, or am I mistaken? My latest source of frustration is upgrade from AutoIt 3.3.10 to 3.3.12, namely its new Excel.au3 include UDF. Functions just disappeared, with no hints of what to replace them with, no comments in the code of the include file that would shed any light on what to do, what's happening... Or am I missing something obvious? How do others deal with it?1 point
-
Kyan Hopefully, the block comment in this script explains the problem you are having with ".+?" in your RE pattern. #include <Array.au3> $json = '[{"Id":"2","button":"#random#","status":"ok"},' & _ '{"Id":"56","button":"#random#","status":"checking"},' & _ '{"Id":"61","button":"#random#","status":">"},' & _ '{"Id":"42","button":"#random#","status":">"},' & _ '{"Id":"43","button":"#random#","status":"ok"},' & _ '{"Id":"45","button":"#random#","status":"failed"}]' $aJSON = StringRegExp($json, '(?i)\{"Id":"(\d+?)","button":"[^:]+:"(?:ok|checking)"\}', 3) #cs $aJSON = StringRegExp($json, '(?i)\{"Id":"(\d+?)","button":".+?","status":"(?:ok|checking)',3) \{"Id":"(\d+?)","button":" matches {"Id":"61","button":" with 61 captured; .+?","status":"(?:ok|checking) means match all characters until the first occurrence of ","status":"(?:ok|checking) is matched. So .+? matches:- #random#","status":">"},' & _ '{"Id":"42","button":"#random#","status":">"},' & _ '{"Id":"43","button":"#random#","status":"ok"} #ce _ArrayDisplay($aJSON) #cs ;Returns:- 2 56 43 #ce1 point
-
1 point
-
Error with Script
232showtime reacted to JLogan3o13 for a topic
First, please do not PM members asking for assistance without being invited to. It is considered rude. I do not have the time at the moment to install RaidCall, and then play with your code to try to fix it for you. Someone more adept with that product may wander along in the meantime; but otherwise you'll need to be patient.1 point -
Error with Script
232showtime reacted to JLogan3o13 for a topic
If you don't understand it, you need to read and figure it out. Everyone has been at Day 1 before, but this forum is dedicated to helping users better their code and their knowledge of AutoIt. You need to take the code line by line, read it and try to figure out what it is doing. Look at Keywords, such as StringSplit, in the help file to see what they are doing. And then look at the Example in the help file for that Keyword to see what it is doing. We're here to help, but mikell is providing you with only 3 lines of code; it is not unreasonable to expect you to figure out what it is doing1 point -
WMI ScriptOMatic tool for AutoIt
UEZ reacted to argumentum for a topic
reply to an old topic but I didn't want to open a new topic. This tool now comes standard in every installation but I wanted to display the results in arrays. So I mod. the code. 2015.11.28 added a StatusBar. ( was not easy to resize in win10 ) fixed COM handler in generated code 2015.06.08 changed the CIMv2 button to switch between CIMv2 and WMI. ( is a more practical use of the button ) added some support for remote connections. ( executes remotely based in the classes discovered in local PC ) added Save to Disk for the filter by right-click the button. ( is anoying having to set it every time ) fix CPU usage was higher than needed in the main loop. ( ..less abuse on the PC ) added the position in the array to the "select properties". ( when an error pops up, the position is there, making it easier to find it in the listview ) 2015.05.25 fixed "Send to ScITE" ( wasn't working well ) added the ability to remove fields/properties from the generated arrays 2015.05.16 fixed the combobox not working everywhere. added setting to, in addition to Dynamic Classes, to include Abstract Classes. added a filter ( easyer to look for what you need ). 2015.05.15 added custom default setting for display array limit. added custom GoogleIt search ( @SelectedClass is the macro word ). added cache for the Class too ( since is much faster and there is no need to discover every time it runs ). change cache from an entry in the ini to a file of its own and created a subfolder for them when in portable mode ( cleaner that way ). changed the function generation to not have to pass an integer. changed function names when longer than 60 characters ( Au3Check don't like infinitely long names ). changed how F5 works. Now F5 runs and ESC stops. changed code generation from "$Output = $Output &" to $sReturn &=". added \root\namespace:class to the title bar. added a class description above the list of methods ( it just makes sense ). change the default spacing of Array_Join() ( to better identify it was joined ). added a watcher for "Autoit error", to move it to the current screen ( ANSI version ). fixed "Send To ScITE" incomplete send ( it was too much at once ). added to "Send To ScITE" the option to send to a new tab or cursor position. added to the ini, Editor='@ScriptDir & "\..\..\SciTE\SciTE.exe"' , to use in a portable setup, it will normally use ShellExecute(,,,"Edit") added the settings of the editor to the settings GUI. added a button to move the settings and cache from @AppDataDir to @ScriptDir ( to carry your settings and cache as portable ) and back again, if so you want to. added a ScITE "installer", to add this app. to the tools menu. 2015.05.12 fixed the way it returns a value when it, is an array. changed the Google it string ( added "example" ). added for all Properties and Methods with a ValueMap, functions to return value ( descriptions ). added cache of namespaces to the ini file ( it was annoyingly slow ). added full help. ( well, a list of all class, property and method Qualifiers ), to be found at the end of the code. 2015.05.11 added refresh after closing the settings GUI to make the changes reflect in the code already in the editbox 2015.05.10 added preferred monitor to display _ArrayDisplay on the ANSI compile changed internal works for Topmost and Multi-monitor so the code shown in the editbox is always clean of extraneous variables to both compiles. 2015.05.09 ( ANSI compile only ) added multi-monitor support to the ANSI compiled, just in case it fails, that's why not both compiles, so no change in the source code. In any case the code it generates is the same. 2015.05.08 added option to Edit after save file ( why else would you save it ) added save path of saved file to ini, when ini file exists. added Send to ScITE ( easier than copy and paste ) changed the default TAB width to 4 ( looks better in ScITE ) 2015.05.07 added keyboard shortcuts Ctrl-F11 to change font size Ctrl-T to change tab sizes the others are the underscore letter with Ctrl instead of Alt key ( but those should work with Alt. by default too ) added settings saving. default is @AppDataDir & '\ScriptOMaticForAutoIt3\ScriptOMatic.ini' but if one is found in @ScriptDir & '\ScriptOMatic.ini' that is the one to be used. changed in the ANSI version to a more useful _ArrayDisplay version. added cleanup on exit. added tab adjustment. added font choosing. added font background color choosing. added User or Admin mode info. to the title bar. added option to set the string inside the cell (<td 'your string'>) for the user to change the default color and style changed the debug info. to ToolTip, to be better aware of running status. changed the way it writes TEXT and HTML to be so every 100 records. added the ability to open the files from failed or prior runs by double-clicking the radio button. changed file creation naming format to better identify them. 2015.05.06 Better readability for HTML and Text outputs. Left the state of the source code ready for the current version. Added a v3.3.12.0 compiled version ( better behavior under Win 8.1 and 10 ) and renamed the ANSI version. 2015.05.05 Fix a logic that would say fail when it was a limited listing of Namespaces, it now tells that the listing is limited. 2015.05.04 Added announcement of Admin. rights ( user might not know ) rethought the "_Array2D_toHtml.au3" to be an #include ( as it should have been ) reworked the Namespace combobox loading went from MsgBox and ToolTip to TrayTip and TrayIconDebug ( less intrusive ) www search now "Google it" ( MSDN change the links format ) Fixed the compiled _ArrayDisplay from displaying off center 2015.05.03 Added an array rotator ( at times I'd rather see it rotated ) Added an array to html ( to see the array on the browser ), that also can be rotated ( it uses the array rotator ) 2015.05.02 Enable Ctrl-A, C, V, X, Z to use the keyboard Prettified the output a bit more and corrected some typos. 2015.05.01 And added press F5 like in ScITE, ( my finger just goes there ) to the Run button. Also a "STOP" to the run ( at times I mess up and need to ProcessClose ) And set $MB_TOPMOST to the MsgBox ( so I don't loose them from sight ) And made the output of the array to be a function ( easier to use in a script ) And prettified the GUI a bit, not much. ==== EoF ==== In the zip is the source code and an AutoIt v3.2.12.1 ANSI compiled file, that should run on any Windows version along with a current AutoIt version compile. Download from here1 point -
Want to Connect function to Enter key
Gianni reacted to ResNullius for a topic
OK what about this: #include <GuiConstantsEx.au3> #include <EditConstants.au3> $TestGui = GUICreate("test") $edit1 = GUICtrlCreateEdit("", 5, 10, 190, 17, $ES_AUTOVSCROLL) $edit2 = GUICtrlCreateEdit("", 5, 40, 190, 17, $ES_AUTOVSCROLL) $edit3 = GUICtrlCreateEdit("", 5, 70, 190, 17, $ES_AUTOVSCROLL) $accEnter = GUICtrlCreateDummy() Global $a_AccelKeys[1][2] = [["{ENTER}", $accEnter]] GUISetAccelerators($a_AccelKeys) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $accEnter If _GuiCtrlGetFocus($TestGui) = $edit2 Then _MyEnterFunc() Else GUISetAccelerators("") ControlSend($TestGui, "", _GuiCtrlGetFocus($TestGui), "{ENTER}") GUISetAccelerators($a_AccelKeys) EndIf EndSwitch WEnd Func _MyEnterFunc() MsgBox(0, "", "Enter Pressed in Edit2") EndFunc ;==>_MyEnterFunc Func _GuiCtrlGetFocus($hGui = "") Local $InputID = ControlGetHandle($hGui, "", ControlGetFocus($hGui)) Return _ControlGetGuiID($InputID) EndFunc ;==>_GuiCtrlGetFocus Func _ControlGetGuiID($hCtrl) Local $Result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hCtrl) If @error = 0 Then Return $Result[0] Return SetError(1, 0, '') EndFunc ;==>_ControlGetGuiID1 point