Jump to content

WaitingForZion

Active Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by WaitingForZion

  1. Although I could not successfully adapt my first complete implementation of an IPC mechanism in C++ to AutoIt through plugins, I would like to suggest a very simple model of IPC on which the implementation was based, so that others with the time available and the idea not yet conceived can implement it themselves according to their own needs. The model works perfectly when implemented correctly. In fact, my IPC plugin did not work as perfectly as intended, not because the implementation of its workings were flawed, but because its interface with AutoIt was flawed, seeing before testing it with AutoIt, it worked quite well as a small C++ class library. The model is very simple, so I do not expect praise upon praise for the concept, but I cannot deny that despite my lousy coding skills and poor creativity, I did indeed imagine it myself. One need only implement a manager for invisible windows whose messages suffice to provide the IPC mechanism for transferring data of any kind and length. In order to send and receive this data from within the main thread, as is the case with AutoIt scripts since only one thread is permitted, the window manager must not only operate in a separate thread, but communicate with the main thread, and permit the creation and destruction of windows used to mediate the communication as directed by the main thread. Therefore, there should be a window that is responsible for creating and destroying the others upon receiving messages representing those directives. This is necessary because only the thread that creates a window can later destroy it or process its messages. Beside that window there must be another kind of window, of which there can be many for a given process, responsible for sending and receiving data through the WM_COPY message. It must convey a reference to itself in all transmissions, and must respond to ordinary yet user-defined windows messages asking whether it is indeed such a window and to what protocol it belongs. Now all this functionality should be encapsulated for ease of use within classes, so that it is not brought to user's mind what is actually happening. I've called instances of these classes augerates, but you can call them whatever you like. But upon this set of classes there should be built one last layer of abstraction, which utilizes the open system discussed so far to implement the appearance of a system of closed connections between applications. For each process, there ought be at least one augerate called a senator. Senators in different processes communicate with each other to provide the name of the process they represent, and to establish connections, creating a phone object in each of the two process whose senators have agreed on a connection. These phones must simply provide methods to send and receive data between each other, and methods to mutually disconnect. Both the senator augerate and the phone augerate must have a protocol that is distinct from each other. Methods in the senators should be provided to test for all process ready to communicate by enumerating through each window, inquiring of its protocol and briefly expecting a response. Upon the appropriate response, the process can then inquire of the name of the senator, and make connections with the process it represents. To take it one step beyond my own implementation, you could implement a service to keep track of all the existing senators, so that you can immediately connect to it by its window name, and rapidly retrieve information about all the senators, instead of briefly waiting through the silence of non-senator windows. Without getting too specific or detailed, those are the basic of the augerate IPC model. It may not be impressive or sophisticated but it works perfectly. Just make sure to avoid memory leaks and deadlocks. If anyone wants my sloppy source code (it may not even be the same as when it worked; I don't know; I could have changed it) just PM me and I'll be glad to send it to you. I'm in college now so I'm learning how to code properly, but I wrote it before I took my first programming class. Let me know if my description is not clear enough so I can give better ones in the future.
  2. This is a simple function I ported over from a program I wrote in VB.NET and C#. It takes any text, such as an essay or a letter, and extracts all the letters that begin each word in their proper order, providing also the absolute position of each letter returned. I find this useful when I want to encode a message in plain text and then have a program detect those codes with the aid of a script. I can't guarantee you an easy day encoding phrases according to this scheme, but decoding is really as simple as the function below. #include <Array.au3> ; #FUNCTION$ =============================================================================== ; ; Name...........: _StringGetFirstLettersOfWords ; Descriptions...: Returns a continous string of the first letters of all words ; in a given string and also provides the positions of each letter, ; in an array. ; Parameters.....: $sText - The text contain all the words. Could be a paragraph, could be anythig ; $aiPositions - An array to which the letters' positions will be added in ; the order of the letters. ; Return Value...: A continous string of all the first letters of all words in the text in their order. ; Author.........: Guido Arbia ; Modified.......: ; Rmearks........: ; Related........: ; Link...........: ; Exaple.........: Yes ; #FUNCTION$ =============================================================================== Func _StringGetFirstLettersOfWords($sText, ByRef $aiPositions) $iPosition = 1 $iLength = StringLen($sText) $iState = 0 $sResult = "" While $iPosition < $iLength $sCurrentChar = StringMid($sText, $iPosition, 1) Switch $iState Case 0 If StringIsAlpha($sCurrentChar) Then If IsArray($aiPositions) Then _ArrayAdd($aiPositions, $iPosition) $sResult &= $sCurrentChar $iState = 1 EndIf Case 1 If Not StringIsAlpha($sCurrentChar) Then $iState = 0 EndIf EndSwitch $iPosition += 1 WEnd return $sResult EndFunc And here is a simple example. $message = "a pleasent place looks excellent" Dim $arr[1] $word = _StringGetFirstLettersOfWords($message) MsgBox(0, $word, "p is located at " & $arr[2]) Let me know what you think.
  3. Well, it works perfectly as a C++ library, but there seems to be some problems adapting it to AutoIt. Even though it's likely a trivial bug, I'm pretty worn out right now. Sorry guys. Just in case anyone runs into problems with this plugin.
  4. The communications are handled through windows messages. Different windows are used for different purposes to achieve the communication, but all of them are invisible and for messaging purposes only. One window is created when you use AugraStartup() from within a newly created thread which handles all the messages in all the windows used by Augra. Messages are then sent to this window from the main thread when you create a new AppSenator object so that that thread can create a new window. A single window is used for each AppSenator and each end of an AppPhone, but the windows for both those things at the core of the code are for the same purpose. The data is always sent using a WM_COPYDATA message. So whatever the limits of that method of transfer is, and the limits of how much memory can be allocated on the heap, those are the limits to the packet size. The data is stored in C++ strings from the standard template library. Also, for this plug-in I did not really distinguish between binary data and strings. They seem do to the same thing as long as you are using the ASCII character set. You might think I dumb for this but, I figured you can get by without it. I'd show the source but I'd be embarrassed by it. Anyway, my code which it wraps is not inaccessible.
  5. Something went wrong when testing it after I uploaded it. I had to fix it. Here's the updated zip. AutoItAugra.zip
  6. This is a plugin I wrote that makes it very very easy to do interprocess communication. Please test it out and report any bugs. Examples and documentation are given in the zip. Please rate and comment. AutoItAugra.zip
  7. Thanks for the help, but now I have another problem. Is it possible to access elements in an array from within a plugin, and to return arrays as well? This would work very well for my project, but I don't see anyway to do it.
  8. I have just recently downloaded the AutoIt Plugin SDK, and have included the two files au3plugin.c and au3plugin.h in my VC++ 2010 Express project. I had expected it to compile, but it generated an error and it seemed that the cause was my mingling of C and C++ code. There were some resolutions to this problem on the web, but I could not succeed with any of them. Is there some way that I can still use C++ to implement my plugins? C is not suitable for me, and its stricter rules I don't like too much. I just want to use the C plugin functions in my C++ code. Is that possible? Thanks.
  9. Is the link list example intended only to be an example, or can we freely use it as a library? If we can, can you please make an explicit claim of authorship at the head of the script, so that no one will get confused if I distribute it along with projects I write that use it? Thanks.
  10. This past week I was not in a place where I could work on my lexer, but for the first few days I was filled with ideas on how to improve it. Sad to say, I have only made one minor update to the library. In the earlier version, the _StringTokenize function would simply ignore all occurrences of characters not associated with a token definition. I understand that in many cases it may not be desirable to allow these occurrences. To remedy this problem, I have merely added a parameter and a few more lines of code allowing you to choose whether you want the function to terminate with an error when this happens. It should be pretty easy to break up all kinds of language structures. Limitations still remain, but they can be worked around. The only severe limitation I can think of, besides the speed limitation that come with being implemented in a scripting language, is the inability to recognize tokens made of characters whose types vary according to order, and tokens made of differing literal characters. There is a simple remedy for the latter. Simply included all possible characters in the token definition, and then after they have been recognize, process them further by filtering. So instead of defining a separate token type for each operator when you have operators represented by more than one character, simply define one token type for all operator characters. After you have your list of tokens, merely filter those tokens identified as the given token type. I'm really sorry for this inconvenience. To make the necessary improvements, I will have to make another implementation taking these things into mind. Update: Alexi 1.0.1.zip Now, does anybody have any ideas or suggestions? Or does anyone have feedback?
  11. I explain that in my improved version: Alexi 1.0
  12. The AutoItObject team has been brilliantly made Object Oriented Programming available in AutoIt. Not too long after they were working on this, I tried to implement a lexical analyzer in AutoIt, but the code became unmanageable due to lack of decomposition and other reasons, so I gave up on it and just release the broken the code. However, with the addition of Object Oriented Programming in AutoIt, I was able to implement my library successfully. This new Object Oriented Library for tokenizing strings is called Alexi. Alexi does away with the need to implement the first step in processing structured language. Alexi itself lets you define token types and split up a string into tokens of those types. Since this is only the first version, there are certain limitations, so not every structure can be tokenized, but for me at least, this is a big step headed in that direction. The library along with documentation and an example is in the zip file attached to this post. Alexi.zip Feedback is appreciated, and I implore you kindly to provide it. Update: Scroll down to other post.
  13. I guess everyone thinks it's garbage. Well, that's ok. But can I have some kind of feedback?
  14. This question is for those who created the AutoItObject library. I think this OOP stuff for AutoIt is awesome. However, I noticed that there is no function to delete created objects. I don't know whether garbage collection with those objects are implemented or even possible. It seems to me that they're not. My question is, if I am writing a script using the AutoItObject library to create many objects, how do I delete those objects later on, or how do I avoid wasting memory?
  15. I was working on a UDF for inclusion in the UDF standard library that breaks text up into tokens based on an array of token definitions. I'm aware that according to good engineering principles code should be decomposed as several functions to make it more human readable. However, since this was a UDF, I did not think it would be approved if I broke up my UDF into smaller functions, so I decided to write this function without any subroutines except for one. You may think I'm inapt to code for saying this, but I'm starting to have trouble understanding my own code. I have nearly succeeded in creating a tokenizer that recognizes specified symbols, sets of characters according to a given regular expression, and in-quote strings. My goal was to create a function that could break up structured information into tokens for easy processing. Unfortunately, because the code is becoming so unmanageable for me, and so disorganized to the point that I can no longer refine it through minor modifications, I've chosen not to complete it. Nevertheless, the function does work successfully with the proper parameters. _Tokenize() takses three arguments. $sText - the text to tokenized. $aTokenTypes - the array of token definitions. $aTokens - The destination array to which shall be added the new tokens. [Type, Text] Each token definition is an array of five elements. 1. The type name of the token. 2. Whether the token will be matched directly with a given single character, or regular expression describing the kind of character. 3. The character/regular expression. 4. Whether the token consists of a single character, or multiple characters each within the class on the one specified character or regular expression. 5. Whether to accept the following characters literally a string under the type of token specified, until it encounters a character of the same token definition. I've never thoroughly studied or understood already developed algorithms for tokenizing or parsing, so this process came from my own limited and faulty idea of how one would work. Any feedback, ideas, etc will be appreciated. #include <Array.au3> $NO_TOKEN = -1 Func _Tokenize($sText, $aTokenTypes, byref $aTokens) $iCharCount = StringLen($sText) $vLastType = 0 $sLastChar = 0 $sCurrentToken = "" $bLastIsSingle = False $bIsSingle = False $bHoldLastChar = False $bInLiteral = False $bStartLiteral = False $bLastStartLiteral = False $sLiteralText = "" Dim $aNewToken[2] For $iCharIndex = 1 to $iCharCount $sChar = StringMid($sText, $iCharIndex, 1) $vType = _CharIdentifyTokenType($sChar, $aTokenTypes, $bIsSingle, $bStartLiteral) if $iCharIndex > 1 Then if NOT $bHoldLastChar Then $sLastChar = StringMid($sText, $iCharIndex-1, 1) $vLastType = _CharIdentifyTokenType($sLastChar, $aTokenTypes, $bLastIsSingle, $bLastStartLiteral) EndIf If $bInLiteral AND $bStartLiteral <> $bLastStartLiteral then $sLiteralText &= $sChar Else $bHoldLastChar = False EndIf if ($vType <> $vLastType OR ($vType == $vLastType AND $bLastIsSingle)) AND $vType <> $NO_TOKEN Then If Not $bInLiteral then If Not $bLastStartLiteral then $aNewToken[0] = $vLastType $aNewToken[1] = $sCurrentToken _ArrayAdd($aTokens, $aNewToken) EndIf If Not $bStartLiteral Then Else $sLiteralText = "" $sLastChar = $sChar $vLastType = $vType $bLastStartLiteral = True $bInLiteral = True $bHoldLastChar = True EndIf Else If ($bStartLiteral AND $bLastStartLiteral) AND ($vType = $vLastType) Then $aNewToken[0] = $vType $aNewToken[1] = $sLiteralText _ArrayAdd($aTokens, $aNewToken) $bInLiteral = False $bHoldLastChar = False EndIf EndIf $sCurrentToken = "" ElseIf $vType = $NO_TOKEN Then $bHoldLastChar = true EndIf If $iCharIndex = $iCharCount AND $vType <> $NO_TOKEN Then if $bInLiteral Then SetError(1) Return -1 EndIf If ($bStartLiteral AND $bLastStartLiteral) AND ($vType = $vLastType) Then $aNewToken[0] = $vType $aNewToken[1] = $sLiteralText _ArrayAdd($aTokens, $aNewToken) Return EndIf $sCurrentToken &= $sChar $aNewToken[0] = $vType $aNewToken[1] = $sCurrentToken _ArrayAdd($aTokens, $aNewToken) Return EndIf If $vType <> $NO_TOKEN Then $sCurrentToken &= $sChar EndIf Else If $vType <> $NO_TOKEN Then If $iCharCount = 1 Then if $bStartLiteral Then SetError(2) Return -1 EndIf $aNewToken[0] = $vType $aNewToken[1] = $sChar _ArrayAdd($aTokens, $aNewToken) Else $sCurrentToken &= $sChar EndIf EndIf EndIf Next EndFunc Func _CharIdentifyTokenType($sChar, $aTokenTypes, byref $bIsSingle, byref $bStartLiteral) For $aType in $aTokenTypes If $aType[1] = true AND StringRegExp($sChar, $aType[2]) Then $bIsSingle = $aType[3] $bStartLiteral = $aType[4] Return $aType[0] ElseIf $aType[2] == $sChar then $bIsSingle = $aType[3] $bStartLiteral = $aType[4] Return $aType[0] EndIf Next $bIsSingle = false $bStartLiteral = False Return $NO_TOKEN EndFunc Dim $tokenDefs[5] Dim $token1[5] Dim $token2[5] Dim $token3[5] Dim $token4[5] Dim $token5[5] $token1[0] = "open_param" $token1[1] = False $token1[2] = "(" $token1[3] = True $token1[4] = False $token2[0] = "close_paren" $token2[1] = False $token2[2] = ")" $token2[3] = True $token2[4] = False $token3[0] = "comma" $token3[1] = False $token3[2] = "," $token3[3] = True $token3[4] = False $token4[0] = "single_alnum_word" $token4[1] = True $token4[2] = "[[:alnum:]]" $token4[3] = False $token4[4] = False $token5[0] = "string" $token5[1] = False $token5[2] = '"' $token5[3] = False $token5[4] = True $tokenDefs[0] = $token1 $tokenDefs[1] = $token2 $tokenDefs[2] = $token3 $tokenDefs[3] = $token4 $tokenDefs[4] = $token5 Dim $tokens[1] if _Tokenize('sandwich(cheese, "confusing solomy", "Another string?", mayonaze, mustard)', $tokenDefs, $tokens) < 0 Then ConsoleWrite(@Error & @CRLF) EndIf for $i = 1 to UBound($tokens)-1 $token = $tokens[$i] ConsoleWrite("Type: " & $token[0] & @CRLF & "Text: " & $token[1] & @CRLF & @CRLF) Next
  16. I've defined a function accepting three parameters, one of which is an array using byref. My function calls the UDF _ArrayAdd to add newly defined arrays to the array passed to the function. The function appears to run properly so far, but when I try to access one of the elements of the added arrays from the referenced main array, AutoIt generates a range error. I attempted to access the 2nd element of the sub array like this: $main_array[1][1]. This is clearly not a index out of bounds error. I've tested my function from within, and the successful execution of my function confirms that there is no error as to the number of elements in the array. The problem is, after I am done adding elements to the array in my function, I am unable to access the elements of the sub-array, or as it seems even the sub arrays themselves. I'd prefer not to post my code here, because I want to keep my project without competitors for now, but if it is absolutely necessary to show my code in order for you to help me, just ask, and I will display it.
  17. The following code creates a seperate script process for a specified function, and execute it. It is in it most rudimentary form, but I see it as the beginning to the solution of multi-threading. Others may have developed a similar solution. I'm not doubting that. However, I'd like to make this small contribution to make up for my earlier slandering of AutoIt and one of its developers. If we can combine this functionality with some form of interprocess communication, we will arrive at a solution or work around for multi-threading. Instead of executing two threads in the same process from the same script (which is impossible), or executing two separate scripts, we can dynamically create a script from a given function, and execute it concurrently with the script that held and called the function. I have not fully developed this. Like I said, it is in its most rudimentary form. But I want to open you to the idea, and to kindle an endeavor to implement it. Also, like I said, it may have been implemented already. I neither knew if it was nor searched to find out. It would have spoiled the fun. So tell me what you think. #include <Array.au3> func ScriptCreateFromFunc($function_name) $this_script = FileOpen(@ScriptFullPath, 0) $new_path = @TempDir & "\" & @ScriptName & "_" & $function_name $new_script = FileOpen($new_path, 2) Dim $lines[1] $lines[0] = 0 if $this_script <> -1 and $new_script <> -1 then do $line = FileReadLine($this_script) $error = @error _ArrayAdd($lines, $line) $lines[0] = $lines[0] + 1 until $error == -1 Else FileClose($this_script) FileClose($new_script) return -1 EndIf FileClose($this_script) $func_point = -1 $end_point = -1 for $i = 1 to $lines[0] $func_path = "Func " & $function_name $func_path_length = StringLen($func_path) if StringLen($lines[$i]) >= $func_path_length then $tmp_line = StringLower(StringLeft($lines[$i], $func_path_length)) if StringLower($func_path) == $tmp_line Then $func_point = $i ExitLoop EndIf EndIf Next if $func_point <> -1 then for $i = $func_point + 1 to $lines[0] $tmp_line = StringLower($lines[$i]) if $tmp_line == "endfunc" Then $end_point = $i ExitLoop EndIf next Else FileClose($new_script) return -1 endif if $end_point <> -1 Then for $i = $func_point + 1 to $end_point - 1 FileWriteLine($new_script, $lines[$i]) Next Else FileClose($new_script) Return -2 EndIf FileClose($new_script) return $new_path EndFunc func ScriptRun($scriptfile) Run(@AutoItExe & " " & $scriptfile) endfunc func myfunc() ;This is the function text. ;This is a function that will run. ;This is the function text. ;This function can be executed as a seperate process. Opt("WinTitleMatchMode", 2) Run("Notepad.exe") WinWait("Notepad") WinActivate("Notepad") Send("Yep, it worked!") EndFunc ScriptRun(ScriptCreateFromFunc("myfunc"))
  18. Looking at the help file, I see that AutoIt has the ability to pass callback pointers to dll functions. Now, from what I understand, AutoIt does not support multi-threading. Others have made this clear to me. Nevertheless, I still tried to use an autoit function as a separate thread by calling it from the a dll. Now, the function appeared to execute as another thread, seeing some of its code was executed in parallel, but then AutoIt terminated with an error. Can someone explain this to me? I'm not imposing multi-threaded functionality on AutoIt, nor am I urging the developers to do it. It was just an experiment. But I would like to know why it failed.
  19. Im sorry, but I was not aware that it was being discussed so much. Ive only been aware of what Ive come across, and I have not come across so many threads on the subject. If the other developers will permit it, I would like to get involved in the development of AutoIt. I know it is not their goal to implement those things, but it is my goal, and if I come to aid in development, I can help extend the language, because I am just as hopeful in the languages potential as are the others.
  20. You have been perfectly clear in what that "them" is yourself: "certain syntactic conveniences"
  21. So then, why do you refuse to implement them?
  22. Now I understand that AutoIt is an excellent language for automating tasks, as I have seen by using it. And there has been mention of advancing the language to make it more complete or more like a regular programming language. These suggestions have been knocked down and the arguments supporting them refuted, but I must admit I am witnessing AutoIt drift in that direction. Now as far as I understand, this drift is not intentional, seeing none of the developers esteem the idea. But it is clear to me that AutoIt is definitely taking on some of the characteristics of a complete programming language, because it now has abilities to do things that a complete programming language would have. Yet the means by which powerful tasks are accomplished in the language are not completely feasible, as they would be in a regular programming language, although the more automating-based tasks are. Therefore, it seems to me just as someone would find a loophole in something and exploit it to accomplish something not directly and easily accessible, it is done the same way in AutoIt. Can someone please explain this to me?
  23. Having grown accustomed to programming languages such as Visual Basic and C+, I am a bit reluctant to indulge in scripting with AutoIt, only because I have little expetation of benefiting from it due to my understanding of the superiority of complete programming languages. But I have heard how powerful this language is when it comes to automating tasks, and I know that this is not so easily done in programming languages like the ones I've mentioned. Therefore, although I am not accustomed to its simplicity, because I look for complex ways of doing things, my weariness of the coding automated tasks in such ways has lead me to settle with AutoIt. So here is my question: How do I combine the easy interface of AuoIt to use for automation, and the more complicated interfaces that are more powerful for other things?
×
×
  • Create New...