Jump to content

TheDcoder

Active Members
  • Posts

    7,103
  • Joined

  • Days Won

    88

Everything posted by TheDcoder

  1. @Dan_555 Nice function, reminds me of a similar function (strseg) that I wrote, but in C It basically does the same thing, search for the next delimiter and return the string. It doesn't have support for the different directions though!
  2. No progress on coding today, but I am studying the syntax and trying to come up with the basic logic I would use to parse the code. I also realized that I lost a never-published update to my example reference script, which is a shame However I lifted the AutoIt help file and the code examples from my VM into a local folder for easy access, this should be good enough to get me started. I guess the main syntax features which must be implemented are: Variables Functions Common expressions
  3. @Jos Indeed, you cannot use only .au3 files to create an extension, you will have to create an interface in JavaScript. If you do that, then you can do pretty much anything from AutoIt
  4. This is technically correct, because Chrome extensions are just a bunch of JavaScript files zipped up. But it is possible to make those scripts communicate with a local program running in the computer... so it is indeed possible to create an extension which uses AutoIt.
  5. You don't have to, working with code doesn't mean only writing low-level C code, there are many other things which can be worked on... such as writing scripts and documentation
  6. @argumentum Those are some very interesting insights, thanks for bringing them up For now I would like to keep it simple, and not try to overly optimize... we can do that once we have the basics working I may or may not change the default chunk size to 8 KB, as it seems to ideal when taking the block sizes of the HDD into account. We are looking at memory vs. disk speed trade-off here, and I imagine the difference would be minuscule practically. The most important part, having an efficient "algorithm", is done. There is only one more method which is better, that is to use platform-native API to query the file size and then read all of that at once, no chunks The current code is a good balance of efficiency combined with portability as everything is written in standard C.
  7. @argumentum That is an interesting choice, can you share the reasoning for 8 kilobytes for each chunk? I chose 1 kilobyte because most text files are in that range and thus are nicely dividable without wasting too much space in the last chunk.
  8. Alright, I finished work on the readfile function, looks pretty solid to me /* * MIT License * * Copyright (c) 2020 Damon Harris <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef READ_FILE_BUFFER_SIZE #define READ_FILE_BUFFER_SIZE 1024 #endif struct ReadFileBufferNode { char buffer[READ_FILE_BUFFER_SIZE]; size_t data_len; struct ReadFileBufferNode *next; }; /// @brief Read the contents of a text file into a dynamically allocated buffer efficiently /// @details This function reads the file in chunks which are stored in a linked list, and then all of the chunks are concatenated /// into a single buffer which perfectly fits the whole string. /// @author Damon Harris ([email protected]) /// @param [in] file Pointer to the FILE to read. /// @returns If success, pointer to dynamically allocated buffer containing the full contents of the file, NULL otherwise in case of an error. char *readfile(FILE *file) { // Define the final buffer char *final_buffer = NULL; size_t final_size = 0; // Define and allocate the initial node struct ReadFileBufferNode *initial_node = malloc(sizeof(struct ReadFileBufferNode)); if (!initial_node) return NULL; // Read the contents of file in chunks struct ReadFileBufferNode *curr_node = initial_node; struct ReadFileBufferNode *next_node; while (true) { // Copy the current chunk size_t bytes_read = fread(curr_node->buffer, 1, READ_FILE_BUFFER_SIZE, file); curr_node->data_len = bytes_read; final_size += bytes_read; if (bytes_read < READ_FILE_BUFFER_SIZE) { // Check if we have an error if (ferror(file)) goto cleanup; // Mark this node as final curr_node->next = NULL; // Break the loop break; } // Allocate the next buffer node next_node = malloc(sizeof(struct ReadFileBufferNode)); if (!next_node) goto cleanup; curr_node->next = next_node; curr_node = next_node; } // Allocate the buffer final_buffer = malloc(final_size + 1); if (!final_buffer) goto cleanup; final_buffer[final_size] = '\0'; // Copy data into the final buffer curr_node = initial_node; char *curr_chunk = final_buffer; do { memcpy(curr_chunk, curr_node->buffer, curr_node->data_len); curr_chunk += curr_node->data_len; curr_node = curr_node->next; } while (curr_node); // Free all nodes cleanup: curr_node = initial_node; do { next_node = curr_node->next; free(curr_node); curr_node = next_node; } while (curr_node); // Return the final buffer return final_buffer; } I can now *finally* begin work on the parser, will do that later today
  9. Alas, I never slept, decided that I should just get up and use it as a leap day to reset my schedule. I slept at 8 PM on that day and woke-up at ~3 AM today, I did some nice work on a function to read the contents of a file but had to stop due to a rather long power outage. Eventually I got a bit tired after breakfast and decided to take a nap around 6-7 AM, that turned out to be a bad decision, as I ended up sleeping/laying in bed for 6 hours! It was just the perfect temperature with cool air and my warm bed, so I couldn't manage to get up even though I was a bit awake. So I did not have much time for coding today. I managed to get my function to a working state: The idea behind the function is that it will read the contents of the file in chunks by using a linked list and then concatenate all of those chunks into a big buffer which is a lot easier to work with. Here is the code for those who are interested, note that it has some rough edges and can be optimized further: It is 8:20 PM now, so I better go and sleep soon. Later guys
  10. I think regular progress reports might be a good idea, it will help keep my motivation afloat Today I read some stuff about parsing, scanning (lexical analysis) etc., but nothing really note-worthy. I still don't have a good idea on the overall design of the code... but I have the big picture in mind, and I guess the code will naturally evolve as I work on it. The first major-ish hurdle is actually reading the code from the file, I was thinking about loading the whole thing into memory as it sounds simple, but I found out that there are not standard C functions to reliably calculate the size of the total stuff in a file, so not very easy unless I resort to platform-specific API. An alternative and in my opinion a better method is to buffer the file, only keeping a part of it in memory. It is pretty easy to do, but the problem arises when we have to work near the boundaries, where a token might be split unevenly. It is 5 AM here right now and I should really head to sleep, my sleep schedule is a bit messed up at the moment Bye!
  11. Hello everyone, Just a small but important update, as of today I have officially started work on the project, and I have chosen to name it EasyCodeIt There are a handful of reasons why I chose that name: It reflects one of the important goals, keeping it easy to code It somewhat makes sense and rhymes with AutoIt By far, it is the only name which hasn't been used by others (DuckDuckGo shows that no results contain that word) It is shorter than other potential names while still being meaningful ...there might be other reasons which I cannot recall right now If I come across a better name, I might change it still, so nothing is set in concrete. I am licensing the code under GPL (v3), a newer version of the same license under which AutoIt3 used to be under. I don't really have a problem with others forking my code, but I sure do not want the forks to be closed source, that is the reason why I did not choose a 100% free license. Eventually we would need exceptions down the road to allow binary distribution of executable without having to require disclosing their own source code. My current aim is to build a bare-minimum cross-platform interpreter which can act as a proof-of-concept, and we can build from there I will release the code publicly once I actually finish something presentable, right now my code is not very different than a simple imitation of command-line tools like cat or type
  12. I see, that is interesting. I do the same, it works good enough when you follow safe practices. Not sure about MalwareBytes, I never used it.
  13. Typical tech support response And it indeed looks like the Ping function in AutoIt has a bug, it should return if a timeout is defined.
  14. I agree. @Soil_Person A BitAND operation in this case just checks for the existence of a flag in a "magic" number, to understand how this works first you have to learn how binary works, then bit-operations are the next step. There are many tutorials and sources you can use to learn, however it is not necessary for you to understand how it works to use it I happened to have made a very simple function, which allows you to check if a flag exists in a magic number, you can use this instead of the BitAND function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: IsMgcNumPresent ; Description ...: Checks if a number is a present in a number (Magic numbers aka Powers of 2) ; Syntax ........: IsMgcNumPresent($iNumber, $iMagicNumber) ; Parameters ....: $iNumber - Number to check if it exists in $iMagicNumber. ; $iMagicNumber - The number which might contain $iNumber. ; Return values .: Success: True ; Failure: False ; Author ........: Damon Harris (TheDcoder) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://git.io/vPFjk ; Example .......: Yes, see IsMgcNumPresent_Example.au3 ; =============================================================================================================================== Func IsMgcNumPresent($iNumber, $iMagicNumber) Return BitAND($iMagicNumber, $iNumber) = $iNumber EndFunc Example for reading checkbox state: ; This function will return True if the passed checkbox is checked Func IsCheckedbox($idBox) Local $iState = GUICtrlRead($idBox) Return IsMgcNumPresent($GUI_CHECKED, $iState) EndFuc
  15. @TheSaint Thanks for sharing bud. The script that I provided was a simplified example of what I was trying to do in C. Right now I am working on porting one of my programs (ProxAllium) to Linux, essentially re-writing it to work across platforms. I encountered this dilemma when I was writing the code for GUI, in C these kind of duplications have a bit more impact on future modification on code as it is a naturally low-level language, so it is best to write "clean" code from the start, as to avoid doing that in the future. Also, as no doubt most of you would have gotten the gist, I do not like redundancy in my code. I actually tackled this problem in my AutoIt code as well, when working on the same program. At that time I came up with another solution: Using a dummy value and artificially trigger the toggle code so that it can properly populate the correct value, I even found a "hack" in AutoIt which lets me kind of simulate GUI events (when using OnEvent mode): Also containing a code example, which practically does the same thing as the previous examples: @argumentum An interesting and out-of-the-box solution, kudos, I may even find an use for it
  16. @jchd Thanks for the suggestion, I will think about it @argumentum G is also taken. Sounds like NodeJS -- Seriously though, thanks for the suggestions, but I won't probably pick any generic or long names. I want it to be short and simple... ideally rhyming with AutoIt, I was thinking about ScriptIt but that was taken already... EasyScriptIt comes to mind but it is too long 😕 @TheSaint has submitted funny names like RabbIt, ManualIt, ForkIt etc. This reminds me of this quote: (Source)
  17. @HansHenrik I am aiming for the former, but during the initial stages I might just directly use the abstract syntax tree skipping the bytecode for the sake of simplicity, which means it will effectively a text interpreter until the software is mature enough. I really want to start work on this but I am having a hard time coming up with a name for the project
  18. @mLipok A suggestion to improve efficiency of the main loop, use HotKeySet to modify a variable (probably a boolean) and check that instead of calling _IsPressed
  19. That is not what I meant, I should have clarified better, the question should have been: From where in the computer are you getting the strings from
  20. Where are these startup paths defined? Do the commands with spaces in file names actually work? Right now there is no clear pattern.
  21. Where do you get $path from? There might be a better way than manually extracting the path than parsing the command.
  22. @argumentum Kudos for the effort! @aVen9er You might also want to consider an alternative method of detection, maybe you can pass custom command line parameters, or maybe even use the @Compiled macro. All of my suggestions of course are generic, it is not possible to suggest the best method without knowing the use case
  23. I have run several AutoIt scripts under wine successfully, it works pretty well. As for AutoIt natively running in Linux, it is pretty much impossible as M23 has pointed out... however, I am planning to start work on a cross-platform port of the AutoIt language, and Linux is the primary target of that project. You can see the thread (link in my signature) that I started a year ago where I discuss it. I hope to start work soon and you may see some results in the coming months.
  24. Indeed, I recall working with negative integers in 3.3.15.x, it certainly looks like the latest beta version has a new algorithm for storage which is not capable of handling negative integers, @Jon Any comments on this matter? @TheSaint Your silly suggestions are certainly not helping my brain think of a proper name
  25. I am not sure I understand, can you elaborate? The only other Map UDF that I am aware of is @iamtheky's wrapper around Scripting.Dictionary, so it is incompatible with my UDF which uses native AutoIt maps. Sure, anyone (including the AutoIt Team) can take my code and make their own UDF. I am unfortunately unable to actively contribute to this effort as I am busy with some other projects and I am not regularly using AutoIt anymore as it is not available for Linux... I do intend to start working on my cross-platform port soon, just need to decide on a good name before I get started
×
×
  • Create New...