SOLVE-SMART Posted January 22, 2022 Share Posted January 22, 2022 Hi folks, personally, I felt it always unclean or simply ugly to include whole UDFs into his script or project, in cases where you need only individual functions from it. The fact that the *.exe gets larger when compiling is often no longer a problem these days or you just don't mind it anymore - I, on the other hand, do somehow 😅 . That's why I used to take the individual functions from the UDFs into my script so that I didn't have to include the entire UDF (#include). Depending on the license, I have recorded the attribution of the UDF creators or the contributors in the credits or similar to keep it fair. Then the change came: I got to know Visual Studio Code (VSCode) professionally, first for other languages, then also for AutoIt. With VSCode's rapidly improving and nowadays very powerful IntelliSense (code completion) I got an idea. Easy and fast: I store functions that I often need or have in some (own) UDFs in snippet files and can quickly insert them into the respective script or project if required. But it's important to me that I can access the functions contained in the snippets from anywhere - on my private computer, at work or at a colleague's/friend's. So I created a VSCode Extension 😀 . VSCode-AutoItSnippets: If you also implement your AutoIt projects with VSCode, then my AutoIt Snippets Extension might interest you or even help you to implement your projects faster. I would be very happy if you could take a look at the project. Of course, I'm interested in your opinion on this as well as whether one or the other would like to share their function(s) and would also like to have them immortalized in the extension 🧐 . If this should be interesting for you, then you are welcome to add your functions via pull request, or just write them here so I can include them in the snippet files, or you write with a private message or email. I'm curious if this can be helpful for you, because there are already over 500 installations of the extension, which makes me happy 😁 . This is how it looks in practice/in use:https://github.com/Sven-Seyfert/VSCode-AutoItSnippets#features Best regards Sven ________________Stay innovative! barkeeper 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2022 Moderators Share Posted January 23, 2022 SOLVE-SMART, Quote I felt it always unclean or simply ugly to include whole UDFs into his script or project, in cases where you need only individual functions from it Just for interest, there is an excellent utility included in the full SciTE4AutoIt3 package called Au3Stripper which will: Strip all unused UDF's (Funcs) and/or unused Global/Local Variables from your main script and all included files PreExpand Global Const Variables Rename Variables and Func names to shorter versions (makes the script quicker) Warn you that the script is likely to have difficulties running if a parameter cannot be determined before run-time M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Danp2 Posted January 23, 2022 Share Posted January 23, 2022 @SOLVE-SMARTDoesn't that create a maintenance nightmare? If When you update a function, then you have to perform that same update to each project where the code was copied, right? 🤔 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 24, 2022 Author Share Posted January 24, 2022 (edited) Hi @Melba23, to be honest with you, I know Au3Stripper but I didn't know how powerful it is and what it can do for me (blame on me 😔). Thank you for the explanation I will have a deeper look in the future. hi @Danp2, principle you're right 👍 with your consideration. I believe it's not that big problem you might think. How often is it the case to change small, one purpose designed methods/functions? Older scripts or even projects might require more maintenance in general besides updating a few functions when it's really necessary to update them. In my experience it's often a good approach to rethink whether there has to be a bigger refactoring or even a redesign of the application. Of course this depends 😅 . The difference to update separate UDF file(s) and re-including them to your projects in comparison to update functions isn't that big in my opinion. As long we are not talking about such things like a package manager (e.g. npm) with third-party code that will be included in the project, we will always have some kind of maintenance duties and work. Still, it could be a maintenance nightmare like you said. If so, I believe it's better to rethink the design because the project concept or structure might be the wrong. Quote Thanks for the interesting thought which lead possibly to an additional updating concept (or even have to). Best regards Sven ________________Stay innovative! Edited January 24, 2022 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 25, 2022 Moderators Share Posted January 25, 2022 (edited) I like the premise of this extension and I believe it could be quite useful. I'd like to see a method to more easily add user snippets from within VSCode, similar to how https://snippet-generator.app/ works. If you could accomplish this, I believe that it would be high adopted. I'm not a fan of having to type !au3, however, I found that the included snippets can be accessed using a keyboard shortcut for "editor.action.showSnippets". Maybe you could add user friendly way to set this shortcut. Keep up the solid work! Edited January 25, 2022 by big_daddy to = the SOLVE-SMART 1 Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted January 25, 2022 Author Share Posted January 25, 2022 (edited) Hi @big_daddy, thank you for your assessment 😀 . 3 hours ago, big_daddy said: I'd like to see a method to more easily add user snippets from within VSCode, similar to how https://snippet-generator.app/ works. Indeed this would be helpful - I will try to find a good appraoch to achieve it. 3 hours ago, big_daddy said: using a keyboard shortcut for "editor.action.showSnippets" I tried it quickly but I am not sure I like it 😅 . I will explain it later (in a separate post, because of a lack of time). By the way, what if I would set "_" as the trigger for IntelliSense (instead of "!au")? Because all other functions which are provided by the "AutoIt" Extension (of Damien, nowadays of @LoganCH) ... ... do the same 😀 . Best regards Sven ________________Stay innovative! Edited January 25, 2022 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 27, 2022 Moderators Share Posted January 27, 2022 I found a few snippet management extensions for VSCode, however, they do not handle AutoIt variables well since $ is the variable identifier for the snippets. I'm not very proficient in managing strings in javascript or I'd just modify one of the extensions. Someone well versed in RegEx could probably make easy work of it. I did find this extension along with this fork that looks promising. I noticed that in your snippets, you are using $$ instead of properly escaping with \\$. This causes the editor to see all AutoIt variables as snippet variables and therefore tabstops. I'd like to suggest a format like seen below with properly escaped AutoIt variables. As for the trigger key, I wouldn't suggest using just an underscore. I would think !a would be a good trigger as I don't see that being typed very frequently. "IsWindowNotResponding": { "prefix": "IsWindowNotResponding", "body": [ "#include <WinAPISys.au3>", "", "If IsWindowNotResponding(\\$${1:hWindow}, ${2|1000,5000,10000,30000|}) Then", "\t$0", "EndIf", "", "; Author ........: Damon Harris (TheDcoder)", "Func IsWindowNotResponding(\\$hWindow, \\$iTimeout = 5000)", "\t_WinAPI_SendMessageTimeout(\\$hWindow, 0, 0, 0, \\$iTimeout, \\$SMTO_ABORTIFHUNG)", "\tReturn @error", "EndFunc" ], "description": "Checks if a Window is not responding" } Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted February 1, 2022 Author Share Posted February 1, 2022 (edited) Hi @big_daddy, sorry for my late response 😅 and thank you for investing the time to have a research 👍 . On 1/27/2022 at 7:05 PM, big_daddy said: [...] they do not handle AutoIt variables well since $ is the variable identifier for the snippets [...] Yes this is unfortunately a problem, but shouldn't be a big one. On 1/27/2022 at 7:05 PM, big_daddy said: I did find this extension along with this fork that looks promising. They were updated in 2018 which could bring a lot of package dependencies problems when it come to relive them up 🙁 . I will do a research on my own. On 1/27/2022 at 7:05 PM, big_daddy said: I'd like to suggest a format like seen below with properly escaped AutoIt variables. I will definitely change to the proper escape pattern 👍 . On 1/27/2022 at 7:05 PM, big_daddy said: As for the trigger key, I wouldn't suggest using just an underscore. I would think !a would be a good trigger as I don't see that being typed very frequently. It's already the case. When you type !a and the IntelliSense of VSCode will show you all the extensions which do have the prefix !au3. But I see your point. This could be a breaking change in a way - but also not - I don't know right now, but lets see what I will do 😁 . Thanks for your input big_daddy cool 😅 . Best regards Sven ________________Stay innovative! Edited February 1, 2022 by SOLVE-SMART big_daddy 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted February 15, 2022 Author Share Posted February 15, 2022 (edited) Hi folks, I released Version v2.1.0, see CHANGELOG.@big_daddy I changed to proper escape pattern ✔ I switched to !_ instead of !au3_, because almost all user defined functions starting with a underscore ⚠ Function names are adjusted to starting with capital letter (after the underscore) to fit more common practise ✔ I still try to provide a user friendly way of snippet generation (the snippet management extensions that you mentioned, aren't that good) ⚠ Next release coming soon 😁 . Best regards Sven ________________Stay innovative! Edited February 16, 2022 by SOLVE-SMART big_daddy and barkeeper 2 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted February 17, 2022 Moderators Share Posted February 17, 2022 I appreciate the improvements. I’ll have some time to mess around with it tomorrow. SOLVE-SMART 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now