Jump to content

SadBunny

Active Members
  • Posts

    1,444
  • Joined

  • Last visited

  • Days Won

    8

Community Answers

  1. SadBunny's post in StringRegExpReplace wildcard issues was marked as the answer   
    Change your:
    $szString = StringRegExpReplace($szString, "data ignore value = *", "new stuff")  to:
    $szString = StringRegExpReplace($szString, "data ignore value =\s*\d+", "new stuff") The asterisk in your version applies to the space before it, so your pattern will match any string that:
    starts with data ignore value = has 0 or more spaces behind that My version should match any string that:
    starts with data ignore value = (like yours) has zero or more whitespace characters behind that string ( s* ) and has one or more digits behind those optional whitespaces ( d+ ) /edit note: untested.
  2. SadBunny's post in trying some simple clicks not work? (noob) was marked as the answer   
    You forgot the comma between "left" and 624.
    Also in the rest of your code, the square brackets (meaning "[" and "]") in the helpfile indicate optional arguments. So a text like "Function _myFunction(arg1 [, arg2])" means that arg1 is necessary, and arg2 is optional.
    So in the case of MouseClick, the helpfile states:
    MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] ) This means that you can do:
    MouseClick("left")
    or
    MouseClick("left", 10, 20) (note: x and y are on the same "level of optional" so to speak, you can choose to either not supply both or supply both)
    or
    MouseClick("left", 10, 20, 2) ("clicks = 1" as an argument means that if you do not specify it, it defaults to 1, in this case we do set it to 2)
    or
    MouseClick("left", 10, 20, 2, 5) (again, "speed = 10" means "default to 10 if not given as argument".)
    Hope this makes it somewhat more clear.
  3. SadBunny's post in Problem with _IsPressed was marked as the answer   
    Ah, ok, so if I understand you correctly, you'd like hotkey 1 ("c") to do the clickyclicky and hotkey 2 ("{f1}") to enable/disable hotkey 1.
    This is easy to build, see the code below. But what I would prefer in your case is just a more "complicated" hotkey, like ctrl+x or alt+x instead of just c. To set these combos as hotkey, use respectively "^x" or "!x" or even "^!x" for ctrl+alt+x. There are many more combinations possible, see the SetHotKey and Send helpfiles for examples.
    But the code that actually does what you described in the last post would be something like this. (Note that the console logs can be removed - it's just to show you what's going on while testing from SciTE )
    #include <Misc.au3> HotKeySet("{F1}", "toggleOtherHotkey") ; link hotkey F1 to a function HotKeySet("c", "doClickyClicky") ; link hotkey c to a function Global $Paused = False While 1 sleep(1000) ; just do nothing at infinitum, the hotkeys will trigger immediately anyway WEnd Func toggleOtherHotkey() $Paused = Not $Paused if $Paused Then HotKeySet("c") ; unset/disable hotkey c ConsoleWrite("Hotkey c disabled." & @CRLF) Else HotKeySet("c", "doClickyClicky") ; link hotkey c to a function ConsoleWrite("Hotkey c enabled." & @CRLF) EndIf EndFunc Func doClickyClicky() ConsoleWrite("Doing the clickyclicky thing!" & @CRLF) ; insert your clicky clicky code here :) EndFunc
  4. SadBunny's post in how to make autoit script monitor keyboard or mouse to call a function? was marked as the answer   
    It's not IsPressed but _IsPressed (includes the underscore). It's in Misc.au3.
    See: https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm
  5. SadBunny's post in ConsoleWrite not working on compiled executable was marked as the answer   
    From the helpfile of ConsoleWrite:
    This does not write to a DOS console unless the script is compiled as a console application.
    Onwards to the helpfile text on "Compiling Scripts with Aut2Exe", which tells us that we can run the Aut2Exe compiler with the /console switch to make is a console application. If you are running from SciTE, you can just press ctrl+F7, which will bring up the Compile dialog, and check the "Create CUI instead of GUI EXE" checkbox before you press the "Compile Script" button.
    Works on my ConsoleWrite'ing hello world testscript
  6. SadBunny's post in String Replace with input box? was marked as the answer   
    You're almost there.
    What you need to change is that the $sString needs to be filled with the text in $input1 when you click the button, not at the start of your script. Also, "$input1" does not give you the contents of the input control stored in $input1, you need ControlGetText for that.
    This is your code with these changes. They're minimal, but I guess this is what you're looking for.
    Also, please tidy your code by pressing ctrl+t (if you're using SciTE 4 autoit3), it helps to make the code readable and can detect some errors before running.
    #include <MsgBoxConstants.au3> ; Replace a blank space (' ') with a - (minus) character. Local $iReplacements = @extended $parentgui = GUICreate("Convert", 600, 620) $input1 = GUICtrlCreateInput("", 10, 10, 200, 200) $input2 = GUICtrlCreateInput("", 300, 10, 200, 200) $convert = GUICtrlCreateButton("Convert", 220, 100, 50, 50) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() GUISetState(@SW_SHOW) Select Case $iMsg = $convert Local $sString = StringReplace(ControlGetText("","", $input1), " ", "-") ControlSetText("Convert", "", "[CLASS:Edit; INSTANCE:2]", $sString) ;($MB_SYSTEMMODAL, "", $iReplacements & " replacements were made and the new string is:" & @CRLF & @CRLF & $sString) EndSelect WEnd
  7. SadBunny's post in Reading HTML files was marked as the answer   
    If the files are not too big and performance isn't a major issue, then loop through the files, and for every file use _FileReadToArray to read the file into an array. Each line will be in the array element corresponding with it's line number, so you can easily pluck out the correct lines and do whatever you want with them.
  8. SadBunny's post in regular expression is not found in dictionary? was marked as the answer   
    $part is not the thing that equals "=", $part.Value is. 
    MsgBox(0, 4, $test.exists($part.Value)) ;this should be true!
  9. SadBunny's post in Array - get the number of the elements was marked as the answer   
    #include <Array.au3> $searchThisSection = "James" $array = IniReadSectionNames("c:\temp\test.ini") msgbox(0,0,_ArraySearch($array, $searchThisSection)) Something like that?
    ... if I paste your data in my ini file and run it, I get a msgbox stating "2". That is what you mean, I guess? If not, please post more example code. Merely mentioning a variable called "$inputsearch2" doesn't tell us a whole lot about the situation in question
  10. SadBunny's post in Checking to see if @Min is either 1 more or 1 less then Mod(x, 5) = 0 was marked as the answer   
    Note that <any integer> mod <n> is anywhere between 0 .. (n-1). So another way to put it is:
    Func _isValueWithinRangeFromMultipleOfN($value, $range, $n) $modulo = Mod($value, $n) Return ($modulo <= $range Or $modulo >= $n-$range) EndFunc ;==>_checker With this function you could do your task by saying _is...(@Min, 1, 5). But if you decide tomorrow you'd rather check for an interval of 10 minutes with a range of 2 minutes before and after, just do _is...(@Min, 2, 10).
  11. SadBunny's post in How to capture stdout stream? was marked as the answer   
    Check the help file of the "StdoutRead" function. It has a nice and simple example script 
  12. SadBunny's post in how to get a number located after a name from within a string? was marked as the answer   
    Here, a quick test in expresso. I also refined your pattern somewhat, and included a line in your testset with multiple rowspans on the same line. Don't know what you want to do if you encounter those, don't know if you ever would encounter those, but still, it came to mind.

    One thing you should realize is why this actually gets the numbers: it's because the d+, i.e. the 1 or more digits you are looking for, is (inside brackets). That's a "capture group". The StringRegExp with mode 3 ($STR_REGEXPARRAYGLOBALMATCH) returns an array of substrings matching that capture group.

    One problem with regex is that there's quite a variation in the default behaviour of parsers, so if it's important, you always want to test as many scenarios as possible.

    In AU3:
    #include <Array.au3> $s = '<TD ROWSPAN=3 BGCOLOR="#99CCFF">Sales</TD>' & @CRLF $s = $s & '<td rowspan= " 2 ">' & @CRLF $s = $s & '<td style="width:400px;" rowspan = '' 5 '' ...</td>' & @CRLF $s = $s & '<td rowspan = '' 6''</td><td rowspan = '' 7''</td>' _ArrayDisplay(StringRegExp($s, "(?i)rowspan\s*=\s*[""']?\s*(\d+)", 3))
    Note, just to be complete in case you didn't already know: when including " in a "string", or a ' in a 'string', like in this pattern and in this example string, you need to double the quote to "escape" it and not break the string, otherwise you'll get syntax errors. So:
    $s = "This string ""contains"" double doublequotes." $s = 'This string ''contains'' double singlequotes.' Hope this helps a bit in your understanding.
×
×
  • Create New...