Jump to content

gordo

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by gordo

  1. Thanks, that definitely works better -- it no longer cuts off the last character.
  2. Thanks for the timely info. It worked exactly as requested. I had to change the double == to a single one though... Now if I can only figure out how to deal with _readfiletoarray and its strange propensity for adding CR's to array strings... I've implemented StringTrimRight to strip off the CR, but the last line is always a doozie. If the file ends with a CR, I get an extra blank record. If the file ends at the last character of the last word, then after trimming, the last string is cut off by a character. Because of this, I can never get all the strings to evaluate properly. #include <file.au3> Dim $whitelist If Not _FileReadToArray("c:\whitelist.txt",$whitelist) Then MsgBox(4096,"Error", " Error reading whitelist to array:" & @error) Exit EndIf For $x = 1 to $whitelist[0] $whitelist_trimmed = StringTrimRight($whitelist[$x], 1) Msgbox(0,'Record:' & $x, $whitelist_trimmed) Next
  3. Hmmm... I think that just might do it. Thanks! Does ExitLoop exit out of the For loop? I need it to stay in the While loop after testing.
  4. I am working on a script where I am trying to have it parse through a whitelist of arbitrary size. I've read the whitelist file into an array. Now, I want it to process the main instructions only if the comparison string ($new_list[$process_number][0]) is not found in the whitelist. I've gone so far as using a set of nested IF statements to accomplish this task. In the below case, it works for a whitelist consisting of exactly five strings, but won't work for a whitelist of any other size. Can I utilize some kind of loop to perform this whitelist testing? Here's a snippet... While 1 Sleep(500) If $new_list[$process_number][0] <> $whitelist[1] Then If $new_list[$process_number][0] <> $whitelist[2] Then If $new_list[$process_number][0] <> $whitelist[3] Then If $new_list[$process_number][0] <> $whitelist[4] Then If $new_list[$process_number][0] <> $whitelist[5] Then ***MAIN INSTRUCTIONS SNIPPED*** EndIf EndIf EndIf EndIf EndIf WEnd By the way, I'm aware that whitelist[0] contains the total number of strings in the whitelist, but I'm not sure how to use this piece of information to accomplish this task...
  5. I'm no programmer by any means. The learning curve for something like C++ is just too steep for me to put the time in now, with a full time job and all... I started goofing around with AutoIT 3.1 about 6 weeks ago, and in that time, I've managed to create a few useful scripts, including a simple client-server application that monitors my computer remotely, has a reasonably small memory footprint and takes up 0% processing time for the most part. Cool! So... I was daydreaming today and wondered whether it was realistic to use AutoIT to create real commercial quality programs... It seems to be a very powerful language that's capable of performing just about any task I can think of (though, truthfully I really don't have much to reference it against.) Anyway, in a single click I can compile a script to an exe that will run on any Windows machine. I can probably figure out a way to tie such an exe to a basic installshield-type program, read and write registry keys and for the most part, quack like a real application. Perhaps I won't obtain the kind of real-time performance that a C++ or assembly tweaked app gets, but considering I've proven my ability to hen peck my way through the function reference and ended up with some useful scripts in a matter of hours, I wondered whether I'm dreaming here, or if anyone has done or considered something along these lines already? Incidentally, I'm aware that the AutoIT functions are available through DLLs so that other apps can take advantage of its functions, but what I'm wondering is whether AutoIT is worthy of being considered a standalone programming language in its own right... or have I just not run up against its limitations?
  6. I suppose that's the answer... I was hoping to use an array for simplicity's sake, but it looks as if that filereadarray function is just too limited for my needs.
  7. I'm not creating or writing to the file in my script, I'm just trying to parse an existing, manually created file, so I don't think the FileWrite command would help. Thanks anyway.
  8. I'm using _fileradtoarray to parse a simple text file I created. When reading the file into an array, it's clearly recognizing each new line by the carriage return character, but it's also adding this character to each array value. How do I prevent this from happening? You can recreate this effect by creating a file in Notepad called c:\test.txt with several lines of [Enter] delimited text. Then run this script and you can see that the array value gets the carriage return added: #include <file.au3> Dim $array If Not _FileReadToArray("c:\test.txt",$array) Then MsgBox(4096,"Error", " Error reading file:" & @error) Exit EndIf While 1 If WinActive("Untitled - Notepad") Then ControlClick("Untitled - Notepad", "", 15) Send($array[1]) EndIf sleep(1000) WEnd
  9. AdLibEnable is such a strange function. It does run in its own internal loop and will max out CPU unless the next command is a sleep(x). But when exactly is the sleep function evaluated? I just don't get it. It doesn't seem to matter what length of time you sleep for either, as the sleep function is not fully evaluated... Can anyone explain what exactly is going on here? Oh, also, each of these lines error out on my computer. How come and what do they do? Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"ExitEvent") TraySetState()
  10. Ok, so here's a test script I created that seems to do the trick, although I'm not exactly sure whether this is an efficient way to accomplish my task. I assume that with this structure, I can just keep adding functions and the main program will loop through each one. Is this the right way to go about this? Will this scale to let's say 100 functions without killing the CPU even if I speed up the sleep periods? While 1 AdlibEnable ("notepad_hello", 1000) Sleep (1000) AdlibEnable ("wordpad_goodbye", 1000) Sleep (1000) WEnd Exit Func notepad_hello() If WinActive("Untitled - Notepad") Then ControlClick("Untitled - Notepad", "", 15) Send("hello") Sleep(2000) WinKill("Untitled - Notepad") EndIf EndFunc Func wordpad_goodbye() If WinActive("Document - WordPad") Then ControlClick("Document - WordPad", "", 59648) Send("goodbye") Sleep(2000) WinKill("Document - WordPad") EndIf EndFunc
  11. Thanks, I'll give it a shot.
  12. I'm wondering if there's a way to have AutoIT constantly listen in the background for certain triggers like key combinations or window pop-ups, and automatically perform certain scripted actions and then go back to a listening state for the next trigger... until the process is killed. Is there a way to make such a listener as some sort of uber-script with all actions included as subroutines or is there another external facility that provides for this capability?
×
×
  • Create New...