jvanegmond Posted May 23, 2011 Share Posted May 23, 2011 Threads like always catch my eye. Primarily not because I really want object oriented AutoIt (I do btw - a lot), but because people are using AutoIt in fun and creative ways. That gives you, reader, a pretty good idea of what this thread is all about. It's a mind teaser, to provoke thought.Look at what Kip has done with his preprocessor (and a history of others before him), the possibilities are seemingly endless. By creating a preprocessor for AutoIt (not the kind that simply improves execution speed), we can do more with the language than what is officially available to us. The question central to this thread is:What cool and fun things can we do with AutoIt?I'm always trying out new languages when I get an opportunity. With seeing more and more of other languages always comes envy of other language features. I am quite sure that anyone who reads this and knows another language will go "True, i've always wanted [...] in AutoIt". There are possible through a preprocessor which produces (even neatly looking) AutoIt code to reach this goal. I've some simple ideas to get the thread started.When keywordinspired by await$finished = False When PixelGetColor(100, 100) == 0xFF00FF MouseClick("Left", 100, 100) $finished = True EndWhen While Not $finished Sleep(100) WEndThis can be compiled to:$finished = False AdlibRegister("__implDetail__When01", 100) While Not $finished Sleep(100) WEnd Func __implDetail__When01() If PixelGetColor(100, 100) == 0xFF00FF Then MouseClick("Left", 100, 100) $finished = True EndIf EndFuncThe trick is to determine the right amount of sleep it needs automagically (it's a private implementation detail after all). Perhaps 100ms is a good default choice, but some will need to define it themselves.Inline functions (maybe even called delegates)Inspired by Lua inline functions.HotKeySet("a", Func() Send("b") EndFunc)Actual code:HotKeySet("a", "__GenericFunctionName01") Func __GenericFunctionName01() Send("b") EndFuncHow this works is that any time you use Func() it is replaced with a function name (as string), and the function statements are preprocessed into a new function with that name.Moar! github.com/jvanegmond Link to comment Share on other sites More sharing options...
Mat Posted May 23, 2011 Share Posted May 23, 2011 I think the best way to implement this would be a generic preprocessor that then has community written plugins. Ideally it would be AutoIt, as we all know that well, but I doubt it's feasible as a plugin language. The plugins would install hooks for the different syntactical elements and could then have a series of methods they can call on the script to change the output. AutoIt Project Listing Link to comment Share on other sites More sharing options...
James Posted May 23, 2011 Share Posted May 23, 2011 Man if we had closures and alike, I'd die a little. Ternary would also be nice. $aVal = true $myVal = ($aVal ? "hello" : "world") But I don't think that can be as easily processed as what you mentioned Manadar. I can see this turning into a "I wish AutoIt had..." list. But hey.. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
jvanegmond Posted May 23, 2011 Author Share Posted May 23, 2011 (edited) Man if we had closures and alike, I'd die a little. Ternary would also be nice. $aVal = true $myVal = ($aVal ? "hello" : "world") But I don't think that can be as easily processed as what you mentioned Manadar. I can see this turning into a "I wish AutoIt had..." list. But hey.. That can be preprocessed into: $aVal = true $myVal = _Iif($aVal, "hello", "world") Have a look in the help file for _Iif. We can include it if it's not already in the script. It stands for "if and only if". I didn't know that for a long time. http://en.wikipedia.org/wiki/If_and_only_if Also, let's make this an "I wish AutoIt had .. and let's add it right now" thread. Edited May 23, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
James Posted May 23, 2011 Share Posted May 23, 2011 Also, let's make this an "I wish AutoIt had .. and let's add it right now" thread.I wish AutoIt had....ClosuresTernaryWas object orientated, optionally like PHP say....All I can think of for now. I quite like the limitations in place, except for those mentioned above. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
jvanegmond Posted May 23, 2011 Author Share Posted May 23, 2011 I wish AutoIt had....ClosuresTernaryWas object orientated, optionally like PHP say....All I can think of for now. I quite like the limitations in place, except for those mentioned above.And how would you implement them? That's key. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 23, 2011 Share Posted May 23, 2011 New syntax is always fun to write. That's one of the things that always hung me on AutoIt.Net. There are features that .Net would require (or would be required for the AutoIter to target .Net) that are just weird to design while still remaining inside the AutoIt style. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 17, 2012 Author Share Posted September 17, 2012 I was taking a shower and came up with this:ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) Func a($b = c()) Return $b EndFunc Func c() Return 5 EndFuncFor the uninitiated, the above yields: Badly formatted "Func" statement.: Func a($b = c())Preprocesses into:ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) Func a($b = Default) If $b = Default Then $b = c() Return $b EndFunc Func c() Return 5 EndFuncAbusing (or misusing) Default for this purpose yields a leaky abstraction. Perhaps it is better to use @NUMPARAMS for this purpose. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Bowmore Posted September 17, 2012 Share Posted September 17, 2012 I was taking a shower and came up with this: ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) Func a($b = c()) Return $b EndFunc Func c() Return 5 EndFunc For the uninitiated, the above yields: Badly formatted "Func" statement.: Func a($b = c()) Preprocesses into: Func a($b = Default) If $b = Default Then $b = c() Return $b EndFunc Abusing (or misusing) Default for this purpose yields a leaky abstraction. Perhaps it is better to use @NUMPARAMS for this purpose. Why do you concider using Default in this manner to by a misuse of Default. I often use it like this. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
jvanegmond Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) Why do you concider using Default in this manner to by a misuse of Default. I often use it like this. I dug up an old thread, so it's possible you didn't read the first post. I'm looking at ways to use a preprocessor to transparently add functionality to AutoIt. If you look at this bit of code:ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) ConsoleWrite(a(Default) & @CRLF) Func a($b = c()) Return $b EndFunc Func c() Return 5 EndFunc It's the functional equivalent of:ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) ConsoleWrite(a(Default) & @CRLF) Func a($b = 5) Return $b EndFunc Which has the following output:3 5 (The result of calling c, since $b was not passed) Default Where as if you preprocess it into what I described above:ConsoleWrite(a(3) & @CRLF) ConsoleWrite(a() & @CRLF) ConsoleWrite(a(Default) & @CRLF) Func a($b = Default) If $b = Default Then $b = c() Return $b EndFunc Func c() Return 5 EndFunc The result is:3 5 5 This is how an implementation detail in a preprocessor breaks user code unexpectedly because of the leaky abstraction. You can (I think) fix it by using @numparams. Edited September 17, 2012 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
czardas Posted September 17, 2012 Share Posted September 17, 2012 Interesting thread Manadar. Been looking at this wiki article, though I imagine you are familiar with the complete history of this subject: Law of Leaky Abstractions states:All non-trivial abstractions, to some degree, are leaky.How long was you in the shower? operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jvanegmond Posted September 17, 2012 Author Share Posted September 17, 2012 (edited) How long was you in the shower?10 minutes, I'm a huge fan of Joel Spolsky. His blog is great. Edited September 17, 2012 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
czardas Posted September 17, 2012 Share Posted September 17, 2012 The theory of programming is very interesting indeed. I sometimes wish I had discovered this much sooner, but that's how the cookie crumbles. I hope the shower didn't leak as much as the code. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Mechaflash Posted September 17, 2012 Share Posted September 17, 2012 Anything that improves on speed of execution and/or coding time, and that eases the programming process, I'm down for it... as long as the additions don't take away from the ease of use of AutoIt and become a complex programming language. The idea of adding features are great, as long as it doesn't increase the time it takes to get from idea to deployment. Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
guinness Posted September 17, 2012 Share Posted September 17, 2012 Ternary would also be nice.Seems like your wish finally came true. James 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
dany Posted September 17, 2012 Share Posted September 17, 2012 When I wrote my first UDF I declared all variables as Local, assuming that just as in perl packages, these variables would only be visible to the functions in the UDF but otherwise hidden for the rest of the script.Unfortunately this wasn't the case. I think this would be a good feature (data encapsulation), although being somewhat like a closure I can imagine it's very hard to actually implement.Just my two cents.Seems like your wish finally came true.Cool, I was wishing for ternary as well although _Iif() works just fine. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
James Posted September 17, 2012 Share Posted September 17, 2012 Cool, I was wishing for ternary as well although _Iif() works just fine.It's a feature that IMHO should always have been in the language _Iif is ugly and limited. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
dany Posted September 17, 2012 Share Posted September 17, 2012 _Iif is ugly yea, but I personally haven't run into problems with it sofar. Now I got to find me a piece of wood to knock on... I agree with your humble opinion though. Ever since I first learned about ternary (PHP) I've used it left and right where I could. It's a great shorthand for simple If...Else statements. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
jaberwacky Posted September 17, 2012 Share Posted September 17, 2012 as long as the additions don't take away from the ease of use of AutoIt and become a complex programming language. Also could be stated: "as long as the additions don't take away from the ease of use of AutoIt and become a complex programming language because I don't like change and I don't want to learn." Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
James Posted September 17, 2012 Share Posted September 17, 2012 _Iif is ugly yea, but I personally haven't run into problems with it sofar. Now I got to find me a piece of wood to knock on...I agree with your humble opinion though. Ever since I first learned about ternary (PHP) I've used it left and right where I could. It's a great shorthand for simple If...Else statements.There are times when it's best not to use it though... Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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