Jump to content

Morthawt

Active Members
  • Posts

    680
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Morthawt

  1. Edit (I'd delete but I don't think I can) I think I figured it out. The documentation was a bit spread out but I think I have it figured out. Just not sure about the text alignment thing. Hi. Just experimenting on a little program I am re-making. I have not dealt much with status bars. But I see a minor mention of simple mode but I see no documentation, that I have found any way, to say what it is? I had to do a consolewrite and add the constants include to even find out what number the supplied variable went to (I figured they'd always supply the number as well as the variable, but that's besides the point here lol) What is a simple mode status bar? How come there's no simple mode for the create function but there is for the SetText function for it? I am just a bit confused. I eventually managed to get it to where I can set text which is good for what I need but I would like to know what simple mode is? Also a bonus question, is it possible to align the text like centre, right etc on a status bar?
  2. I have a friend learning Python and he asked me if AutoIt has Associative Arrays (Dictionaries) and if I could write something in AutoIt to help him. Firstly, I never even heard of that kind of array and I found some reference from a couple years or so ago saying it was in the beta. Is that still in the pipeline to come into the final release of AutoIt?
  3. My snippit for the modern Yubikeys (where you have USB Descriptor option enabled on it, via the personalisation tool settings screen) This simply waits until it detects that you inserted your Yubikey and then when you remove it, it locks the PC. But you could use it for all kinds of things, make the PC shutdown, sound an alarm, who knows. Just a cool little thing I threw together. I do not know, really, about "Objects" and dealing with the indepth Microsoft device info but I was able to tweak a basic "here's a list of all USB devices" I found, into something that can detect the presence of the Yubikey. I also have an alternative to USB\\ which will look for smartcards but I stopped using that and reverted back to USB since I am not entirely sure if the numbers represented on there are unique, at least the USB one I can clearly see it has the serial number on my Yubikey. AutoItSetOption('TrayAutoPause', 0) Global $Status, $InitialLaunch = True While 1 $checking = CheckForYubikeyExistence() Switch $checking Case True ;;;;;;;; Area to run commands after the Yubikey is inserted BELOW ConsoleWrite('DETECTED!' & @LF) ;;;;;;;; Area to run commands after the Yubikey is inserted ABOVE While 1 If CheckForYubikeyExistence() = False Then ExitLoop Sleep(100) WEnd Case False If $InitialLaunch = True Then ; Treat it as ready but actually nothing will happen until the Yubikey is inserted and then removed... ConsoleWrite('Launching and waiting for Yubikey insertion...' & @LF) While 1 ; This waits until the Yubikey is plugged in the first time, to initiate the protection readiness or at least, the forthcoming detection of Yubikey removal. If CheckForYubikeyExistence() = True Then $InitialLaunch = False ContinueCase EndIf Sleep(100) WEnd EndIf ;;;;;;;; Area to run commands after the Yubikey is pulled out BELOW ConsoleWrite('WARNING, YUBIKEY NOT PRESENT!!' & @LF) Run('rundll32.exe user32.dll,LockWorkStation') ;;;;;;;; Area to run commands after the Yubikey is pulled out ABOVE While 1 ; This waits until the Yubikey is inserted again before doing anything next. If CheckForYubikeyExistence() = True Then ExitLoop Sleep(100) WEnd EndSwitch WEnd Func CheckForYubikeyExistence($_list_all = False) ; Calling this with a True parameter puts it into debugging mode, to list all the user input or smart card devices depending on what type of devices it is looking for. $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity where DeviceID like 'USB\\%'") ; SCFILTER\\% for smartcards and USB\\% for all USB devices If IsObj($colItems) Then For $objItem In $colItems If $_list_all = True Then ConsoleWrite($objItem.DeviceID & @LF) ; Show all the ID's of all smartcards, so you know which ones are allowed (only plug in ones you want to allow when listing them all) Switch $objItem.DeviceID Case 'USB\VID_1050&PID_0407\0006297461' ; An allowed Yubikey device ID (Your Yubikey needs enabling, on the Settings section of the YK personalisation tool, the "USB Descriptor" option. Else it won't show up. $InitialLaunch = False SetError(0) Return True Case 'USB\VID_1050&PID_0116\0005286976' ; An allowed Yubikey device ID two $InitialLaunch = False SetError(0) Return True EndSwitch Next SetError(1) Return False ;Nothing by now was detected as being an authorised Yubikey. EndIf EndFunc ;==>CheckForYubikeyExistence
  4. When you are encrypting data, I am used to setting the algorithm. But I saw $CALG_USERKEY in the documentation but I have no context as to what algorithm that is. The documentation says it is value 0. I would appreciate a heads up on what $CALG_USERKEY is for? Thanks.
  5. I have been trying to send text to "controls" which I left the last clicked thing on the window but all attempts to controlsend to the window are failing. Controlclicks are not working. I cannot seemingly set text, interact with anything on the window even with specific window-based coordinates using controlclicks?
  6. I finally got around to making a new tutorial on ini files https://www.youtube.com/watch?v=0_cPWYQ6iIs&index=20&list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z I had several requests to do the video on the additional way to pull multiple unknown things from ini files, so I have now done the video.
  7. I'd rather stick with the 3 gram practically bomb proof sealed black-box design of the Yubikey which is designed in all aspects to keep the encryption private keys stuck inside never to be released.
  8. I don't think you understand what a Yubikey is. It is not just something that spits out a password or something. It is capable of doing that as one of it's features, but it is a cutting edge cryptographic security token. It has U2F (universal 2-factor authentication), various OTP (one-time password) capabilities, OpenPGP key based operations like decryption and signing from within the unit, smartcard operations like digital signature authentication, physical access, etc etc. You can also set in the modern ones the QR codes to your 2-factor using services so that rather than have an app on your computer or phone with all the private data, your private data is in the Yubikey and the resulting one-time codes are accessible at the time they are needed with the private keys never leaving the device.
  9. It has been some years since this was posted. I had made my own just now and I thought I would share it here than make a whole new thread: #include <Crypt.au3> Global $otp, $APIid = 00000000, $error, $CustSalt = '7F34E3F39F7967B38A9CEB3C3EE55F17BF9552F8F7A5B74', $AuthorisedHashedPubID = '0x6F25B171D3563C000F75455EAFFA1AA967EAB605' ; Get your API ID ($APIid) by registering for an API key: https://upgrade.yubico.com/getapikey/ ; Use your own custom salt value above so that all the hashes will be entirely unique to your implementation. $otp = InputBox('Yubikey OTP Request', 'Press the OTP Button on your Yubikey', Default, '*') ; Obtain the OTP from the user, by them pressing the button on their Yubikey that is inserted. $nousedonce = StringTrimLeft(HashThis(StringReplace(Random(), '.', '') & @MSEC & StringReplace(Random(), '.', '') & StringReplace(Random(), '.', '') & @SEC & @MSEC), 2) ; This is the "number, used once" which actually is random data, not a number. ;;;;; Prep area, uncomment to generate a working hash to check the person's Yubikey "Public Identity" prefix to generate a salted hash you can check in the future to authenticate their Yubikey ;~ ClipPut(HashThis('ccccccjlgpht')) ; Paste the first 12 characters of a genuine Yubikey OTR that you wish to authorise to access this program and copy the resulting salted hash ;~ Exit ;;;;; $url = 'https://api.yubico.com/wsapi/2.0/verify?otp=' & $otp & '&id=' & $APIid & '&nonce=' & $nousedonce & '&timestamp=1' ; Constructing the URL needed to check with the remote server about a Yubikey's OTP output. $results = InetRead($url, 1) ; Sending the request to the API server. If Not @error Then $results = BinaryToString($results) $split = StringSplit($results, @CRLF, 3) ; Breaking the resulting feedback from the API server up into lines (array rows) so parameters can be ensured they start from the beginning of each line. If StringInStr($results, 'otp=' & $otp) And StringInStr($results, 'nonce=' & $nousedonce) And StringInStr($results, 'status=OK') Then ; If OTP and nonce that were sent to server are the same ones returned & status is OK, continue validation. For $a In $split If StringInStr($a, 'otp=', 1) Then ; If this row of the array contains the otp parameter (it starts at the beginning of the string) then... $a = StringReplace($a, 'otp=', '') ; Strip away the parameter prefix of "otp=" If HashThis(StringMid($a, 1, 12)) = $AuthorisedHashedPubID Then ; If the newly salted & hashed Yubikey's Public ID matches the existing salted hash of the authorised user, then do the immediately following thing... MsgBox(0, 'SUCCESS', 'Successfully authenticated the authorised user''s Yubikey') Else ; If we got here, the OTP that was generated was valid but the particular Yubikey was not one authorised for use with this program, so instead, do the following thing. MsgBox(0, 'Error', 'While the Yubico OTP was validated as genuine,' & @CRLF & 'this Yubikey is not authorised for access.') EndIf EndIf Next ElseIf Not StringInStr($results, 'status=OK') Then ; If the status is anything other than "OK" there is a problem with the OTP that was generated, perhaps it was an old used one? etc. For $a In $split If StringInStr($a, 'status=', 1) Then $error = StringReplace($a, 'status=', '') ; set the error code supplied by the API server in the $error variable. Next MsgBox(0, 'Error', 'Yubico authentication error: ' & $error) ; Display the error to the user. EndIf Else MsgBox(0, 'Error', 'Error accessing Yubico API address.') ; There was a problem accessing the API server, perhaps an internet problem or SSL problem. EndIf Func HashThis($_input) ; Simply does the salted hashing and provides the result $_hash = StringTrimLeft(_Crypt_HashData($CustSalt & $_input, $CALG_SHA1), 0) Return $_hash EndFunc ;==>HashThis My goal was to not have the required public ID stored in the source of the program, yet be able to check when it is the correct one.
  10. Well it was providing the serial number as part of what ever it was. But now it no longer works for the new Yubikeys. I would need to know the new device type and possibly a different thing that contains the serial number in it to check. Here is what the preferences of the Yubikey personalisation tool says:
  11. Someone here gave me some help in order to detect if my Yubikey is inserted or not, by checking the Windows system for all "keyboard" devices for the presence of the serial number of my Yubikey. Then once unplugged and found to be missing, take some action like lock the PC. The problem is it does not work with the newer Yubikeys because, I think, they act as smartcards or something. So the code looking for a keyboard is no good. There was some kind of tool which I used to help me find what to search for I think, I do not remember. Here is the function which did the original checking, but I am totally clueless on how to tweak it to again be able to find the serial number of my new (no longer acting as a keyboard) Yubikey. Func CheckForYubikey($input) $Output = "" $object = ObjGet("winmgmts:\\" & $strComputer & "\ROOT\CIMV2") $items = $object.ExecQuery("SELECT DeviceID FROM Win32_Keyboard", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($items) Then For $objItem In $items FileWriteLine('test.txt', $objItem.DeviceID) If StringInStr($objItem.DeviceID, $YubikeySerialNumber) Then Return True Next Else Return False EndIf Return False EndFunc ;==>CheckForYubikey Any help would be appreciated.
  12. You're welcome. Glad there are people out there finding this capability as useful as I have over the years. It has really helped me when API's are not available and pages need breaking down, as well as API's where JSON information needs breaking down so I can get a particular parameter's data from it. I've used it for getting bitcoin exchange rates, finding new products on websites, seeing a new entry in a top40 charts, seeing when show notes for a new podcast are added to a site, see when the price of a product online goes down and alert me about the lower price, alert me to new threads in a "need help" section of my phone carrier's website. Just endless use I have gotten out of my original Chunk. This new ChunkV2 is so much nicer. If the site gets updated and your chunk zones no longer work, all you need to do is just make new chunk zones that will re-acquire the chunks you need and the rest of your code should be fine still.
  13. I have updated and added a new option 32. I was having problems with some product pages that the site owner would comment out, modularly, products for which are no longer sold or are entirely out of stock. So me trying to make a program to scan for new products was causing all kinds of problems by showing tons of items that appear in the source code, all formatted nicely but in fact aren't actually "there", so if he uncommented those products I would not get notified because ChunkV2 had technically seen the items listed in the page's sourcecode. I had to google for the regex string and add a !? on the end because the guy's site I am interacting with finished some comments with --!> and sometimes --> By the way, here is a real-world example of using ChunkV2 #include <includes\ChunkV2.au3> #include <Array.au3> AutoItSetOption('TrayAutoPause', 0) Global $Zones[4][2], $Zones2[2][2], $PreviouslySeen[0], $url = "https://www.heinnie.com/all-products" $PreviouslySeen = FileReadToArray('productlist.txt') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Zones[0][0] = '<ul id="productlist"' $Zones[0][1] = '</ul>' $Zones[1][0] = '<li class="item">' $Zones[1][1] = '</li>' $Zones[2][0] = '<h2 class="product-name">' $Zones[2][1] = '</h2>' $Zones[3][0] = '" title="' $Zones[3][1] = '">' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Zones2[0][0] = '<ul id="productlist"' $Zones2[0][1] = '</ul>' $Zones2[1][0] = '<li class="item">' $Zones2[1][1] = '</li>' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 $source = _INetGetSource($url, False) $Results = ChunkV2($source, $Zones) ; Returns raw product names $Results2 = ChunkV2($source, $Zones2) ; Returns the entire block of code for each product, so the count will be the same as the product names above. (no subscript errors) Local $new = False For $a = 0 To UBound($Results) - 1 $product = ((StringInStr($Results2[$a], '<div class="ukfriendlycarry">')) ? ('(UK Legal)' & @TAB) : (@TAB & @TAB & @TAB)) & $Results[$a] $test = _ArraySearch($PreviouslySeen, $product) If $test < 0 Then $new = True ConsoleWrite($product & @LF) FileWriteLine('productlist.txt', $product) If Not IsArray($PreviouslySeen) Then Global $PreviouslySeen[0] ReDim $PreviouslySeen[UBound($PreviouslySeen) + 1] $PreviouslySeen[UBound($PreviouslySeen) - 1] = $product EndIf Next If $new Then Beep(500, 1000) Sleep(300000) WEnd
  14. Updated: I have simplified the user's options/flags using BitAND rather than arithmetically processing them to whittle them down. I have tested it and it appears to be working well. Maybe it will slightly increase the speed at which it operates but it has certainly dropped the line count.
  15. Updated to be a single call function rather than calling multiple times to set and run, also added an option for verbose debugging.
  16. Updated and added some information. Basics of updates are: An option modification to remove leading/trailing spaces from the end results as well because I was having issues with such spacing in results. A new option to remove repeated spaces from results, because again I ran into this problem. Added some error detection, details in first post on examples of using it.
  17. For example, you see a top 40 music charts web page and you want to make an AutoIt script to check it now and then and let you know when something new comes up. This UDF helps you to get the raw list of data so that you can make use of it. Or perhaps your favourite web-store has a "New Items" page and you would like to be the first to see new items. You can look at the source code of the web page and use your find feature of your browser to find areas of the source code that get you closer and closer and use this UDF to get the raw data, perhaps two sets of data, one for the product titles and another for the URL's so you could quickly see new products. So many uses. I have used this on my phone carrier's forum so that I can help the new guys by detecting every 10 seconds when a new un-replied-to post has been made so that I can help them out instead of randomly manually checking in the hopes that someone made a thread while I am in the mood to help out etc. #include-once #include <String.au3> #include <Inet.au3> Global $_Cassensitive = 1, $_StripLEADTRAILSpaceFromSrc = 2, $_StripLineFeedsFromSrc = 4, $_StripLEADTRAILTABSFromSrc = 8, $_StripConsecutiveSpacesFromResults = 16, $_StripHTMLComments = 32, $_DebugMode = 8192, $_DebugConsole, $_optionsChosen ; #FUNCTION# ==================================================================================================================== ; Name ..........: ChunkV2 ; Description ...: A new version of Morthawt's Chunk UDF, to break apart web page source code etc into component parts to get at particular pieces of data, such as a top 40 music charts listing by ; using the html formatting to gradually break the source up into a reliable way to get parts of the information. ; Syntax ........: ChunkV2($_Source, $_input, [$_options]) ; Parameters ....: $_Source = Either a BINARY variable containing webpage source code OR a STRING containing a web URL. ; $_input = An array containing 2 columns, Before and after, to encapsulate source between <THIS> and <THAT>. 1 row per chunk closer and closer. ; $_options = [OPTIONAL] ~ A number in the form of an Integer, which is the sum of all desired options/flags. ; ; Options: ; 1 = case sensitive chunking information ; 2 = Remove trailing and leading space ; 4 = Remove all line feeds (CR and LF) ; 8 = Remove all leading and trailing tabs ; 16 = Remove all duplicate repeated spaces from the end results ; 32 = Remove HTML Comments "<!--Message here--!>" "<!--Message here-->" (Single and multi-line) ; 8192 = Add verbose debugging code to the console (Can slow down the entire process quite a lot) ; ; Return values .: An array of pieces of strings that your goal is to obtain. ; Author ........: Morthawt ; Modified ......: 2017-07-04 13:47 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: as follows based on the web page source code being: "<First><Second>Hello</Second></First><First><Second>Hello again</Second></First>" ; ;~ #include <includes\ChunkV2.au3> ;~ Global $Zones[2][2], $url = "https://www.morthawt.com/chunkv2-example.txt" ;~ $Zones[0][0] = "<First>" ;~ $Zones[0][1] = "</First>" ;~ $Zones[1][0] = "<Second>" ;~ $Zones[1][1] = "</Second>" ;~ $source = InetRead($url, 3) ; $source will contain a BINARY version of the source code. ;~ $Results = ChunkV2($source, $Zones, 1 + 16) ; I could substitute $source for $url and it would still work. Uses options 1 and 16 ;~ If @error Then ;~ $er = @error ; Would display the error code which would correspond to the parameter most likely responsible starting with 1 for first parameter. ;~ $ex = @extended ; In the case of extended information, such as a particular Zone row where a failure to match occurred, store this for use in the below message box. ;~ MsgBox(0, $er & " " & $ex, $Results) ; Since this IF statment happens only during an error, the result from ChunkV2 function will be a string containing English information to help troubleshoot. ;~ Exit ;~ EndIf ;~ For $a In $Results ;~ ConsoleWrite($a & @LF) ;~ Next ; ; =============================================================================================================================== Func ChunkV2($_Source, $_input, $_options = 0) $_optionsChosen = $_options $_DebugConsole = ((BitAND($_optionsChosen, $_DebugMode)) ? (1) : (0)) ; Sets $_DebugConsole to 1 if 1 makes up part of the user's options, else sets it to 0. If Not IsArray($_input) Then SetError(2) $_ChunkErrMsg = 'Chunk zones are not in a 2 column array format.' If $_DebugConsole Then ConsoleWrite('!Error: ' & 2 & @CRLF & $_ChunkErrMsg & @CRLF & @CRLF) SetError(2) EndIf Return $_ChunkErrMsg EndIf If IsBinary($_Source) Then $_Source = BinaryToString($_Source) ; Brings the source code of the web page back into string format. ElseIf IsString($_Source) Then If $_DebugConsole Then ConsoleWrite('Getting sourcecode for: ' & $_Source & @CRLF & @CRLF) $_Source = _INetGetSource($_Source, True) If @error Then SetError(1) $_ChunkErrMsg = 'Problem downloading webpage sourcecode.' If $_DebugConsole Then ConsoleWrite('!Error: ' & 1 & @CRLF & $_ChunkErrMsg & @CRLF & @CRLF) SetError(1) EndIf Return $_ChunkErrMsg EndIf Else SetError(1) $_ChunkErrMsg = 'Webpage sourcecode was not in Binary format.' If $_DebugConsole Then ConsoleWrite('!Error: ' & 1 & @CRLF & $_ChunkErrMsg & @CRLF & @CRLF) SetError(1) EndIf Return $_ChunkErrMsg EndIf If BitAND($_optionsChosen, $_StripHTMLComments) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_Source = StringRegExpReplace($_Source, '<!--[\s\S]*?--!?>', '') ; This will remove HTML comments from the source code, handy when people leave old code there commented, throwing non-wanted entries in your results. EndIf If BitAND($_optionsChosen, $_StripLEADTRAILSpaceFromSrc) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_Source = StringStripWS($_Source, 3) ; Removes leading and trailing spaces if user wants If $_DebugConsole Then ConsoleWrite('Removing leading and trailing spaces.' & @CRLF & @CRLF) EndIf If BitAND($_optionsChosen, $_StripLEADTRAILTABSFromSrc) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_Source = StringRegExpReplace($_Source, '(?m)^\t+', '') ; Removes leading and trailing tabs that are used to visually and logically format web sourcecode to make getting at data easier. $_Source = StringRegExpReplace($_Source, '(?m)\t+$', '') ; Removes leading and trailing tabs that are used to visually and logically format web sourcecode to make getting at data easier. If $_DebugConsole Then ConsoleWrite('Removing leading and trailing tabs from the webpage sourcecode.' & @CRLF & @CRLF) EndIf If BitAND($_optionsChosen, $_StripLineFeedsFromSrc) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_Source = StringReplace($_Source, @CR, '') ; Strips line feeds and carridge returns if desired by the user's preferences/flags $_Source = StringReplace($_Source, @LF, '') ; Strips line feeds and carridge returns if desired by the user's preferences/flags If $_DebugConsole Then ConsoleWrite('Removing linefeeds and carridge returns from the webpage sourcecode.' & @CRLF & @CRLF) EndIf Global $_ChunksNeedingProcessing[1] = [$_Source] ; Initiates a new array with a single entry that has the entirity of the web page source code, this array will be replaced with all-new rows with previously pared down data needing ; further breaking down to obtain the actual data desired by the user. For $_The = 0 To UBound($_input) - 1 If $_DebugConsole Then ConsoleWrite('Processing chunk-zone: ' & $_The & @CRLF & @CRLF) _ProcessBetweens($_input[$_The][0], $_input[$_The][1]) ; This runs as many times as there are before/after zones needing to pare the source code down and down to reach the desired data. If @error Then SetError(-1, $_The) $_ChunkErrMsg = 'Error occurred with Zone array row: ' & $_The & ', this row number is documented in @extended for further use. Webpage source could have changed or there are no further results if you are checking consecutive numbered pages and you reached one that does not exist or lacks desired chunked data.' If $_DebugConsole Then ConsoleWrite('!Error: ' & - 1 & @CRLF & $_ChunkErrMsg & @CRLF & @CRLF) SetError(-1, $_The) EndIf Return $_ChunkErrMsg EndIf Next If $_DebugConsole Then ConsoleWrite('COMPLETED.' & @CRLF & @CRLF) Return $_ChunksNeedingProcessing ; Returns the resulting data desired by the user, such as a top 40 list of chart music from a web page table containing a list etc. EndFunc ;==>ChunkV2 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProcessBetweens ; Description ...: Internal UDF usage to do the heavy lifting of breaking a page's source code down into chunks. ; Syntax ........: _ProcessBetweens($_Start, $_End) ; Parameters ....: $_Start - The string that preceeds the parts you want. ; $_End - The string that terminates the parts you want. ; Return values .: None ; Author ........: Morthawt ; Modified ......: ; Remarks .......: This is iteratively called to narrow down the code, paring parts away to provide an array listing the data you wanted from the page. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ProcessBetweens($_Start, $_End) ; Uses an already established array which contains the current break-down-level of the source code and uses provided before/after zones to further break the source down. Local $_tempBuffer[0] For $_go In $_ChunksNeedingProcessing $_tmp = _StringBetween($_go, $_Start, $_End, Default, ((BitAND($_optionsChosen, $_Cassensitive)) ? (1) : (0))) ; Case sensitive is set to 1 if the option for this was part of the ChunkV2's options. Else it will be set to 0 If Not @error Then For $_go2 In $_tmp If BitAND($_optionsChosen, $_StripLEADTRAILSpaceFromSrc) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_go2 = StringStripWS($_go2, 3) ; Newly added to remove lead/trail spaces from results that weren't resolved by removing them from the raw page sourcecode. If $_DebugConsole Then ConsoleWrite('Removing leading and trailing spaces from the final results.' & @CRLF & @CRLF) EndIf If BitAND($_optionsChosen, $_StripLEADTRAILTABSFromSrc) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) $_go2 = StringRegExpReplace($_go2, '(?m)^\t+', '') ; Newly added to remove lead/trail tabs from results that weren't resolved by removing them from the raw page sourcecode. $_go2 = StringRegExpReplace($_go2, '(?m)\t+$', '') ; Newly added to remove lead/trail tabs from results that weren't resolved by removing them from the raw page sourcecode. If $_DebugConsole Then ConsoleWrite('Removing leading and trailing tabs from the final results that weren''t solved via removing them from the source.' & @CRLF & @CRLF) EndIf ; The above additions for space/tab could be removed if I can process the web sourcecode better MAYBE. If BitAND($_optionsChosen, $_StripConsecutiveSpacesFromResults) Then ; If The right option is a component of the full options chosen by the user, the perform the following additional task(s) If $_DebugConsole Then ConsoleWrite('Removing consecutive spaces.' & @CRLF & @CRLF) $_go2 = StringRegExpReplace($_go2, '\s+', ' ') EndIf ReDim $_tempBuffer[UBound($_tempBuffer) + 1] $_tempBuffer[UBound($_tempBuffer) - 1] = $_go2 Next Else ; If there was an error breaking the source code into chunks (such as no desired strings detected or the source was missing valid zones), throw an error up that can be detected in the main ChunkV2 function and sent back to the calling script. SetError(1) Return EndIf $_ChunksNeedingProcessing = $_tempBuffer Next EndFunc ;==>_ProcessBetweens Example of use: (as follows based on the web page source code being: "<First><Second>Hello</Second></First><First><Second>Hello again</Second></First>") #include <includes\ChunkV2.au3> Global $Zones[2][2], $url = "https://www.morthawt.com/chunkv2-example.txt" $Zones[0][0] = "<First>" $Zones[0][1] = "</First>" $Zones[1][0] = "<Second>" $Zones[1][1] = "</Second>" $source = InetRead($url, 3) ; $source will contain a BINARY version of the source code. $Results = ChunkV2($source, $Zones, 1 + 16) ; I could substitute $source for $url and it would still work. Uses options 1 and 16 If @error Then $er = @error ; Would display the error code which would correspond to the parameter most likely responsible starting with 1 for first parameter. $ex = @extended ; In the case of extended information, such as a particular Zone row where a failure to match occurred, store this for use in the below message box. MsgBox(0, $er & " " & $ex, $Results) ; Since this IF statment happens only during an error, the result from ChunkV2 function will be a string containing English information to help troubleshoot. Exit EndIf For $a In $Results ConsoleWrite($a & @LF) Next It may not be the most elegant code but it so far is working. This is an upgraded, written from scratch, version of Chunk UDF that I wrote a long time ago and I think I posted that here somewhere too. Updated: I added a new flag/option 32 which removes comments from the HTML, to prevent non-relevant "results" from showing up when people just comment out, for example, products no longer sold. Updated: I have simplified the user's options/flags using BitAND rather than arithmetically processing them to whittle them down. Updated the format of calling the function, to make it a single line call as you would normally expect to call a function. I did away with needing static variables or arrays. I have added an option for verbose debugging to console. Updated to include the removal of repeated spaces anywhere in each resulting array entry, as I was having problems with this on yet another site. Also added some error detection, so that I can for example infinitely parse a site number of successive pages and when an error occurs (because either the page source is different or there are no "results") then I can either end the script or for example if each section of a site is categorised by letter and then pages per letter like 15 pages of A's, then once it gets to page 16 and errors out due to the failure to pull results, a script can have an @error check and exitloop to continue to B and restart from a new 0 count for the page etc. Updated to process the removal of leading and trailing spaces or tabs from each individual result, because my tests on http://uk.ign.com/games/pc?sortBy=title&sortOrder=asc&startIndex=0 were showing tons of leading and trailing spaces on the results, even though the source had all trailing and leading spaces supposedly removed from it.
  18. Seems I needed to leave a sleep after copying something because the attempt to get the clipboard was done too soon after sending a ^c
  19. I am not sure what is going on, I am not used to this not working. I test it by going to run command and type something, select all and copy. Then do a messagebox that shows the text as ClipGet() and it is blank even though blatantly the clipboard has the data because I can paste it in notepad. What on earth could I be doing wrong?
  20. I am formulating some ingredients for an in sect repellent and I am looking for results where by each component ingredient has no more than 2 decimal places. I have that done but instead of going up 1 gram at a time I decided to try and go up a 10th of a gram at a time, here's a simple count: For $a = 0 To 100 Step 0.1 ConsoleWrite($a & @CRLF) Next What I get instead is by the time it reaches 6.9, it should go to 7 but it goes: 5.99999999999999 6.09999999999999 6.19999999999999 6.29999999999999 I cannot make sense of it. I know once my loop gets to 100 gram area it always is a match but this for loop never yielded any results for me. Only when I added a consolewrite for the loop variable counter did I see this weirdness above. Does anyone know what is going on?
  21. Here is a sample script I made. Originally the gui was inside a function (as the one I am working on is) but that did not work so I commented out the func and I still see no way of seeing any GUI editing capability anywhere in the entire program: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Sleep(3000) ;~ CreateGUI() ;~ Func CreateGUI() #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 148, 81, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25) $Input1 = GUICtrlCreateInput("Input1", 8, 40, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;~ EndFunc ;==>CreateGUI
  22. I have looked up and down and I find nothing in there about GUI or forms other than a folder on the right which looks like it is about forms but nothing is in there and the script I am using does have 2 forms in it.
  23. I thought this was that cool looking (but I think abondoned) Koda replacement someone made with AutoIt it's self. But this I think is not it. Plus I do not see anything in here to do with a GUI. So I am a bit confused.
×
×
  • Create New...