Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/18/2014 in all areas

  1. Last Update - 12/25/2013 Here are a few functions that will take any Autoit code and convert it to RTF format with AutoIt syntax highlighted. The code can be saved or applied right to the RichEdit control you are working with. Special thanks go to MrCreator. A good amount of ideas for different parts of the code and regular expressions came from studying his >Autoit Syntax Highlight for HTMLBBCode. Viewing how he handled certain situations was very helpful. Thanks to Robjong also for feedback on some of the SRE expressions. Update - 12/25/2013 Fixed incorrect coloring for INI functions Update - 10/29/2013 Heres my latest version. Its been completly rewritten in assembly and is working very fast. The previous version for this library worked by checking for each catagory (variable, keyword, string, etc) one catagory at a time using reg expressions. The libaray works by walking the data one time adds the coloring each time it hits a catagory. Each time we hit a catogory, we jump to that catagoys procedure and continue processing until that catagory is over, then return to the main loop, or another catagorey. This make processing parts like comments and strings very fast. For strings Im passing the data to an autoit function for the send keys. For the UDFs im also passing the data to an auto it function, but only to check if its a function, not modify any data. Using a dictionary, I setup a structure where the key is the function name and the item for that key is the length. Checking to see if a key exists in a dictionary is very fast, so is the lookup so if it is a key, I pass back the length of the funtion, along with the function type (Native, UDF, Keyword). Code for Native functions and Keywords are built into the assembly code, the reason they are also in the udfs is for case insensitve checks. The assembly code then adds the coloring and copys the bytes specifed by the length. There full assembly code is in the build folder. That includes everything you need compile the full function if you wanted to change it somehow. Theres also a short little brief on assembly code in general and working with strings in assembly. Update - 10/20/2013 Please let me know if you have any problems. Thanks Change Log: RESH.zip RESHv2.zip RESHv2.1.zip RESHv2.2.zip RESHv2.3.zip asm version: RESHv3.zip RESHv3.1.zip
    1 point
  2. I pointed you to my code, you chose to use the OP's code that isn't safe (as I tried to point out to that OP, but they'll learn as you did). Try this (keep in mind, I have no idea what you've declared or what you're doing really, this is pseudo code only): #include <IE.au3> Local $oIE = _IECreate($url[0], 0, 1, 0) Local $a_temp For $cPage = 1 to $tPage-1 $oIE.Navigate($url[$cPage], 0x0800) $a_temp = __IE_TabLoadWait($oIE, $url[$cPage], "url") ; much safer If Not @error Then $tab[$cPage] = $a_temp[1] Next Do Local $qData = _IEBodyReadHTML($tab[$tPage-1]) ; i assume it's in the body? $load = StringRegExp($qData, 'SORT.*point" style="d') ; no idea if this works Until $load <> 0 ; this will return the objects of the tabs matching type/str and wait if need be Func __IE_TabLoadWait(ByRef $o_obj, $s_str = "", $s_type = "", $n_msecexpire = 0) If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_objret = 0 Local $n_timer = TimerInit() While 1 $a_objret = __IE_GetTabObjs($o_obj, $s_str, $s_type) If IsArray($a_objret) Then ExitLoop ; return if we set the wait timer and it's reached If $n_msecexpire > 0 Then If $n_timer >= $n_msecexpire Then Return SetError(2, 0, 0) EndIf EndIf Sleep(250) WEnd If Not IsArray($a_objret) Then Return SetError(3, 0, 0) EndIf ; set normal _ieloadwait default If $n_msecexpire < 1 Then $n_msecexpire = -1 For $i = 1 To UBound($a_objret) - 1 _IELoadWait($a_objret[$i], 0, $n_msecexpire) Next ; this could return multiple if there is more than 1 tab ; with the same url/title for $s_type passed Return $a_objret EndFunc ; returns all the instances of tabs matching type/str criteria Func __IE_GetTabObjs(ByRef $o_obj, $s_str = "", $s_type = "") If Not IsObj($o_obj) Then Return SetError(1, 0, 0) EndIf Local $a_otabs[101], $i_add = 0, $i_next = 1, $o_ieattach $s_type = StringLower($s_type) While 1 ; we start at instance 1 and enum as we find more instances $o_ieattach = _IEAttach($o_obj, "instance", $i_next + 1) If @error = $_IEStatus_NoMatch Or Not IsObj($o_ieattach) Then ExitLoop ; control array size If Mod($i_add + 1, 100) = $i_add Then ReDim $a_otabs[$i_add + 101] EndIf Switch StringLower($s_type) Case "url" If String(Execute("$o_ieattach.locationurl")) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case "title" If WinGetText(String(Execute("$o_ieattach.hwnd"))) = $s_str Then $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndIf Case Else $i_add += 1 $a_otabs[$i_add] = $o_ieattach EndSwitch $i_next += 1 WEnd If $i_add = 0 Then Return SetError(2, 0, 0) ReDim $a_otabs[$i_add + 1] $a_otabs[0] = $i_add Return $a_otabs EndFunc
    1 point
  3. I'm pretty sure I provided a much safer routine yesterday for this???
    1 point
  4. qwert

    Live Regex

    That's a handy tool for those of us trying to get a handle on Regex. It took me a couple of tries to get it operating (e.g., with quotes or not), so I thought I would post this example using a Regex pattern that was posted today ("StringTrim vs Regex"). Thanks for providing your script.
    1 point
  5. JLogan3o13

    String Trim or RegExp?

    It is one of those things I keep telling myself I need to become more proficient at, but unfortunately it still makes my eyes bleed...
    1 point
  6. jaberwacky

    Themes for SciTE

    On this page I found print.style. http://www.distasis.com/cpp/scitetip.htm I can't find it documented in the official scite docs though. It's worth a try I guess.
    1 point
  7. SmOke_N

    String Trim or RegExp?

    If the numbers are always at the beginning of the line, and they are always only 8 characters, you have the simplest solution above. Here's a regex method to return an array, it doesn't assume that the phone number will be always at the beginning of the line. It also makes exception for different types of setups. eg. area code + prefix + line number prefix + line number You can see below. #include <Array.au3> Global $gsz_Str = "394-4885 random descriptions" & @CRLF $gsz_Str &= "(555)390-7454" & @CRLF $gsz_Str &= "391-5007 random descriptions" & @CRLF $gsz_Str &= "555.394.3021" & @CRLF $gsz_Str &= "398-6879 random descriptions" & @CRLF $gsz_Str &= "555-390-3547 random descriptions" & @CRLF $gsz_Str &= "390-0450" & @CRLF $gsz_Str &= "(555) 392-6940" Global $ga_Numbers = StringRegExp($gsz_str, "(?m)^.*?((?:(?:\W)?\d{3}\W+)?\d{3}\W\d{4})", 3) _ArrayDisplay($ga_Numbers) It's been a while since I've been able to play with regex, forgot how much I enjoyed it.
    1 point
  8. This function returns the document source after any client-side modifications (e.g. by AutoIt or by client-side JavaScript). It may therefore be different than what is shown by the browser View Source or by _INetGetSource().
    1 point
  9. This is a piece of code that I use. This may help. #include <INet.au3> Local $Source = _INetGetSource("http://forum.powweb.com/online.php?who=members") If StringInStr($Source, "Welcome back,") = 0 Then MsgBox(48 + 4096, "Oh No!!", "Can't even read the page!", 2) ;If text doesn't exist If StringInStr($Source, "The server is too busy at the moment.") <> 0 Then MsgBox(48 + 4096, "Oh No!!", "Busy server.", 2) ;If text does exist
    1 point
  10. Have you tried using _INetGetSourceCould be worth a try.
    1 point
  11. JLogan3o13

    String Trim or RegExp?

    If you want the numbers only (phone number, I'm assuming), and they're always in the same spot, try this: $sString = "367-1111 random blah blah blah" ConsoleWrite(StringLeft($sString, 8) & @CRLF)
    1 point
  12. thanks.. #include <MsgBoxConstants.au3> #include <StringConstants.au3> Local $sString = StringStripWS("1 2 3 4 5.", 8) $iLength = StringLen($sString) MsgBox($MB_SYSTEMMODAL, "", "The length of this string is " & $iLength & " characters.")
    1 point
  13. You are missing the equals bit in your For Next code. For $i To $iMax-1 Step 1 ;iMax is the array size, calculated by UBound ControlSend ($handle3, "", "[CLASSNN:TEdit5]",$arrayEuroShell[$i]) Next should be something like For $i = 1 To $iMax-1 Step 1 ;iMax is the array size, calculated by UBound ControlSend ($handle3, "", "[CLASSNN:TEdit5]",$arrayEuroShell[$i]) Next NEXT tells $i to increment by the STEP value ... or by one if there is no Step value. It will do this until $i equals $iMax - 1 $i starts at the value between equals (=) and TO. In this case 1.
    1 point
  14. Si WMI seems to be good.. A way could be to use WinAPI functions LsaEnumerateLogonSessions + LsaGetLogonSessionData... but it seems to be hard (for me). Another way could be to use an external tool like SysInternals LogonSessions.
    1 point
  15. The query command is available only in the native system32 folder (c:windowssystem32). If you are using a x64 Windows and a x86 script, then try to set the full path to the command, using the sysnative folder. Local $cmd = "c:\windows\sysnative\query session"
    1 point
  16. Just so everyone (who does't know) knows, before we ship the UDFs with the latest AutoIt, jpm runs a unit test which consists of including all the UDFs in a single script to see if there are any issues of possible variable duplication. If it fails we fix it, if it doesn't then of course everyone is happy!
    1 point
  17. @error = 3 means: $vRange is invalid. As far as I understand your code does not return the value of the last cell in column B but the row number of the last cell in column B. Could you please try: $oAppl = _Excel_Open() $sWorkbook = "C:\Users\" & @UserName & "\Documentstest.xlsx" $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Dim $LNC Global Const $xlUp = -4162 ;global constant for Excel up, finding last row $LNC = $oWorkbook.ActiveSheet.Range("B65535").End($xlUp) $sResult = _Excel_RangeRead($oWorkbook, Default, $LNC, 1) MsgBox(0, "last row", $sResult)
    1 point
  18. Thanks Danyfirex. I see your Code and it works. It does not work. I got this error... thanks for yout time.... Saludos
    1 point
×
×
  • Create New...