
squid808
Members-
Posts
16 -
Joined
-
Last visited
Everything posted by squid808
-
I was working on an older script I made that installs and configures McAfee at work. But, due to the nature of McAfee, there was a lot of times when it would stall or hang. No problem for me, since I knew what it was waiting for, but my coworkers who also used the script weren't as lucky. So I figured, hey, wouldn't it be nice if I could have an optional debug? I have DebugIt, but that isn't as easy to use as I had wanted. I started adding tooltips, but they always showed up and I had to keep retyping the coordinates. Plus, it was confusing on an actual hang - am I seeing a tooltip of what was about to happen or what just happened? That's where this comes in. Here's an example of what you might've had before: tooltip("Running Notepad",@DesktopWidth/2,0) ShellExecute("notepad.exe") tooltip("Waiting for Notepad to open",@DesktopWidth/2,0) winwaitactive("Untitled - Notepad") tooltip("Sending ""Hello""",@DesktopWidth/2,0) send("hello") sleep(1000) for $i = 1 to 5 step 1 tooltip("Sleeping " & $i,@DesktopWidth/2,0) sleep(1000) Next tooltip("Waiting for notepad to close",@DesktopWidth/2,0) ProcessClose("notepad.exe") Here you get a single tool tip at the top center of your screen, one at a time. Boooooooring. Instead, you could do this: #include <_ToolTipLog.au3> _ToolTipLogStart("Starting Notepad",2,@DesktopWidth/2,0,"+!s",1) ShellExecute("notepad.exe") _ToolTipLog("Waiting for Notepad to Open") winwaitactive("Untitled - Notepad") _ToolTipLog("Sending Hello") send("hello") sleep(1000) for $i = 1 to 5 step 1 _ToolTipLog("Sleeping " & $i) sleep(1000) Next _ToolTipLog("Waiting for Notepad to Close") ProcessClose("notepad.exe") Now you have... nothing! What the hell? Try running it again, but this time press shift+alt+s and BAM you are suddenly seeing your tooltips. Congrats, you just enabled the on-the-fly debug mode in your script. After the first tip, two things are at the top of the screen: the previous tooltip and the new one. Now, because you placed your tips before an action in the code, you know that the top item is what HAS happened, and the bottom what WANTS to happen. Plus, the subsequent tips retain the position of the last tooltip. Looks like everything is working well, hit shift+alt+s again to turn those tips off (but not other, independant tooltips). In the basics, this will make a running list of whatever you want in a multi-line tooltip. There are two main parts you have to worry about, _ToolTipLogStart() and _ToolTipLog(). When you start, use _ToolTipLogStart(). The only thing you have to define is the text. Subsequent tooltips you want to follow this line are used with _ToolTipLog(). Once a line is out of range to be shown, it is lost. Here are the full parameters: #include <_ToolTipLog.au3> _ToolTipLogStart("text" [, Lines to Show [, x [, y [, Silence Hotkey [, SilenceMode]]]]] ) _ToolTipLog("text" [, Modify Lines to Show [, x [, y]]] ) Options for _ToolTipLogStart: Text: The text to show in the first tooltip. Lines to show: Default 2, this is how many lines you want to have the tooltip eventually show. It will only show as many as it can until it reaches the max, eg. if you define it as 5 and you have only defined 3 tooltips, you'll only see 3. x: default at mouse, this is the x coordinates y: default at mouse, this is the y coordinates. If you define x and not y, y will default to 0. Silence Hotkey: Default "", This defines the hotkey to toggle the silenced mode on and off. The functions will still continue to run and update even if 'silenced' and not shown. SilenceMode: Default 0. If 1, this will set the tooltips to be hidden by default. If 0, they will be shown. Options for _ToolTipLog: Text: The text to show in subsequent tooltips. The lower in the tooltip you see it, the newer it is. Modify Lines to Show: Default 0, this will change how many lines to show by the number given, including negative numbers. -1 will reduce the lines shown by 1, 1 will increase by 1. As lines that have passed are forgotton, adding lines will rebuild in increments up to the new limit you define. x: Default is the previous value used, setting this will set a new x default. y: Default is the previous value used, setting this will set a new y default. If you define a new x but not y, y will default to 0. So there you have it. If you put it in your script and enable stealth mode, it's a great way have a built-in tracker of what's happening. My plans for it are to add an additional option to set sorting to ascending or descending rather than just the way it is now, and I'm trying to think of a way to make some text static, ie. always saying "This just happened: " before the top tool tip and "This is about to happen: " before the bottom text. *yawns* I think this is good for now. I'm all about the input, please give it a shot and let me know what you think! If you can make it better or more efficient, I welcome the changes! Full code below. _ToolTipLog.au3
-
Clear Hard Drive Space Automatically
squid808 replied to Hadez's topic in AutoIt General Help and Support
I'm too tired to integrate it into what you already have, but give this function a try, making sure you keep the '#include <Date.au3>' in the script. If you call this function, it'll start the search, compare each file date to the current date on the fly, and if it's 5 days or older, delete it. Certainly play around with it and add your memo write where needed, but I think this should do the trick for ya. The key was all in the _DateDiff function, and once I figured out how to use it it worked great. You can fine tune it by searching by days, hours or even minutes if you want. Looks like all you need to do is have it call on this when the HD size is down to the trigger size. If you want it to only keep going until you free up enough space, I would look into adding an if statement at the end of the while loop that checks the HD space again (at that point I'd make it a function); once it gets to y size, exit loop. Hope this helps. Func _deleteOld() $dir = "D:\Files\" $search = FileFindFirstFile($dir & "*.*") ; get all files from the directory If $search = -1 Then ; return an error if the search fails MsgBox(0, "Error", "No files found in the search") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($dir & $file, 1) ; Pulls the file creation time into an array, use 0 for a string $tformatted = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] ; Formatted to work with _DateDiff $iDateCalc = _DateDiff( 'D', $tformatted,_NowCalc()) ;throws the difference of the time in Days into the variable if $iDateCalc > 4 Then filedelete($dir & $file) ;If the value, returned in days, is greater than 4 (5 or higher) delete the file WEnd FileClose($search) EndFunc ;==> _deleteOld() -
Bogus results from standard UDF
squid808 replied to JohnOne's topic in AutoIt General Help and Support
Try adding opt("MouseCoordMode",2) to the top, seems to work for me after that. -
Quick Paste into Cmd Prompt?
squid808 replied to squid808's topic in AutoIt General Help and Support
Thanks UEZ, I've used the Run and @comspec combination before (as well as shell execute) and it would work great if only there was a way to run the subsequent commands from the same window rather than separately. I'll keep looking, though. Maybe there is a way to do it. In the meantime I'm trying to figure out how to use this StdoutRead stuff to capture errors from the non-verbose mode =) -
Hi, Just looking to see if anyone knows a good way to paste into a command prompt window - in the GUI I'm working on it has the option of a verbose mode. When checked it shows you it typing in to the prompt rather than hiding it, but so far I can only get it to work using send() which, when you have a few lines to go through multiple times, gets slow. Also, if anyone has a better way of making sure it activates the CMD window (the title of the window is different in different OSes) that'd be great. Any thoughts? Code snippet: Case $checkverbose = $GUI_CHECKED Run("cmd.exe") winactivate("[CLASS:ConsoleWindowClass]","") winwaitactive("[CLASS:ConsoleWindowClass]","",4) for $i=0 to $maxcount-1 winactivate("[CLASS:ConsoleWindowClass]","") winwaitactive("[CLASS:ConsoleWindowClass]","",4) send(_GUICtrlListView_GetItemText($ListView, $i, 1)) sleep(250) send("{ENTER}") sleep(250) Next winactivate("[CLASS:ConsoleWindowClass]","") winwaitactive("[CLASS:ConsoleWindowClass]","",4) EndSelect
-
I'm trying to make a small autoit script that can take five pieces of information per line, then jumbles them around into a dos type command which is added to a queue list. After I've done this for multiple lines of information send those custom commands to the command prompt to run. I think I've figured out how to do most of it, but I'm stuck on how to input the information. Sometimes I need to input the five bits of info by hand, so I could make a GUI with five input fields. Once I type it in I could hit press a button or hit Enter and it would add it the queue list below the entry fields. However, some times I get this info in either Google Doc or Excel format in cells for lots of users at once, so I'm looking for a way to copy and paste multiple cells or lines into the script area and have it add THOSE to the queue list as well. I hope that makes sense, if not I can really try to elaborate. Any thoughts? Is there a command or control I'm missing somewhere?
-
Use ToolTips to show current script line?
squid808 replied to squid808's topic in AutoIt General Help and Support
Thanks MvGulik, I took a step back and believe that I could still use this rather than a log. Let me explain myself a little. In my needs of this I am mainly using AutoIt at work to install updates and the like on entire labs of computers at a time. The thing is, once in a while I'll misjudge one of my WinWaitActives or not realize the window name changes under certain circumstances or something similar. Thus when I look at the computer and the script seems to be hanging, it's actually just waiting for a window that won't come (there isn't an actual script killing error that I need to debug. My apologies, that may have been a wrong word choice). Usually I just end up wasting time trying to find out where it's hanging and why. I'm trying to cut out the where part. In that sense I still think having a tooltip showing where the script is at would help me not only figure out where my hangs are, but also let me know what my scripts are doing. If I can glance at the screen and know what's happening, it also puts my mind at ease. I'm just looking for an unobtrusive way for my scripts to keep me updated in realtime, that's all. I was hoping to have some kind of script 'wrapper' I could have included in a script that would just output each line into a tooltip before letting it execute if that is possible, or something similar. I'm willing to do the work, it's good learning. I just need some direction since I'm still new to the mindset of scripting. =) -
Use ToolTips to show current script line?
squid808 posted a topic in AutoIt General Help and Support
Hello, I was wondering if there was a way to automatically have a tooltip displayed that would show the current line of code a script is on without manually adding a tooltip after each line? I'm basically looking for output like the line number and the line contents, or even just the line contents. Basically I guess I'm looking for a way to use the tooltips as a debugger type feature without using a separate debugger. I often find that when the scripts I use fail on other computers it's too late to use the debugger anyways =) (Though this one is great http://www.autoitscript.com/forum/index.php?showtopic=35218 ) -
What about this: Is there a way that I can use the keyboard to change a selection, use a pixel search to follow it and a mouse click to make the selection, and repeat? The only issue is that over different themes the selection will be a different color, right?
-
Nope, I often use a variable in the same line as I redefine it to no ill effect. For instance, when I'm working with names I can do something like the following: $name="squid808" $name=stringtrimright($name,stringlen($name)-2) msgbox(0,"Hi","The first two letters of my SN are " & $name) You don't have to worry about having a temporary or swap variable to hold on to things.
-
Hello again. I'm trying to write the second half of a script that will install and configure McAfee 8.7i and then configure it to our company's settings. The problem I'm running into is in the portion of the settings seen below in the attached file, they don't use regular check boxes and as such I can't seem to do anything with them. Compounding the problem is that I can't seem to find any keyboard shortcuts to get the boxes to check (I tried Alt+the entire keyboard, I think. it seems to be mouse click only). Also, the window and the interactive parts of the window resize based on the screen resolution but don't let me resize them (so on some widescreen machines I get the scroll down slider on the side of the check boxes). So yeah. I'm not sure how to go about this one. Since the resolution of the window changes per machine, I'm wary of using any kind of mouse emulation, especially when suddenly there is a slider on some and not others. I thought about moving the selection down with the keyboard and then having autoit try to follow the selection and clicking on what's selected, but i'm not sure if I can do that or if it's possible. At this point, all I can get autoit to do is highlight the entire line and change which line is selected. The rest of the McAfee settings use regular windows and check boxes and fields, so they're not a problem. Just the access protection properties. =\ Any thoughts of what I should use to do this? All I can tell you about that window is what the Window Info tool got for me: Window Info: Title: Access Protection Properties Class: #32770 Control Info (Of the control I am trying to work with): Class: SysListView32 Instance: 2 ClassnameNN: SysListView322 Advanced Mode: [CLASS:SysListView32; INSTANCE:2] ID: 1104 Position: 273, 110 Size: 408, 167 Style: 0x5013080D ExStyle: 0x00000204 Handle: 0x12D101CA
-
Searching registry with RegEnumVal and Key
squid808 replied to squid808's topic in AutoIt General Help and Support
Verified working on my end, good sir. Thank you for the help! I'll be back at my next stumbling block =) -
Searching registry with RegEnumVal and Key
squid808 replied to squid808's topic in AutoIt General Help and Support
Edit: Okay, I lied. Question - why does the output change depending on whether or not I use a string or an Array? Neither of them seem to parse the results properly. This is my code I'm using #include <array.au3> $hkeyloc="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" $AIR="Adobe Air" $results=_regsearch($hkeyloc, $AIR, 7, true) fileopen("C:Documents and settings\administrator\desktop\results.txt",10) ;~$i=0 ;write results to txt file ;~while $i < 4 ;~filewrite("C:Documents and settings\administrator\desktop\results.txt",$results[$i]) ;~filewrite("C:Documents and settings\administrator\desktop\results.txt",@CR) ;~$i=$i+1 ;~wend _arrayDisplay($results) Func RegSearch(... The array window that comes up has the last two entries joined, so instead of looking like... 4 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\DisplayName = Adobe AIR HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\UninstallString = c:\Program Files\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater.exe -arp:uninstall HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\{A2BCA9F1-566C-4805-97D1-7FDC93386723}\DisplayName = Adobe AIR it looks like... 3 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\DisplayName = Adobe AIR HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\Adobe AIR\UninstallString = c:\Program Files\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater.exe -arp:uninstallHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\\{A2BCA9F1-566C-4805-97D1-7FDC93386723}\DisplayName = Adobe AIR which makes it pretty difficult to see what I'm working with. Both the message box and the array aren't displaying this properly. What am I doing wrong? -
Searching registry with RegEnumVal and Key
squid808 replied to squid808's topic in AutoIt General Help and Support
Psalty, that's great. Took me a little while to figure out how to use it (it's my first function I've used) but now I'm trying to figure out how to tweak the output and get what I need. You win the day, sir. -
Searching registry with RegEnumVal and Key
squid808 replied to squid808's topic in AutoIt General Help and Support
Edit: Balls, I didn't see your reply was a link. Reading it. -
Hello, first and foremost this is a great program and the forums have been a great help to me so far. I barely know anything about programming or scripting and after only two weeks I feel like I've learned a great deal. However, my brain is still not conditioned for this 100%, so I need some help. (I'm also longwinded, for that I apologize.) I'm trying to write a script that will uninstall adobe AIR and Acrobat.com for use on a few hundred computers I support at work. Adobe AIR has an installer that, if run by CMD prompt with a -uninstall flag will uninstall all versions (supposedly). Acrobat.com doesn't even give us that grace, it just has an entry in Add/Remove programs (so does AIR). I'd go to the registry and just pull the Uninstall string, but their uninstallation subkeys move around in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ key depending on what version it is. So here's the plan: I plan to use RegEnumKey and RegEnumVal (if possible) to search all subkeys that start with a curly bracket (or eventually all subkeys, some aren't in {}s), search them for any entries that have a value of Adobe AIR or Acrobat.com (Usually in the Display Name entry), and if it matches that pull out the uninstall string entry's value. Then take that value, toss it into a cmd prompt, uninstall, and wipe my hands clean. a) is my logic sound? or would this not work due to an obvious flaw? b ) my first stumbling block is trying to use the 'for' loop like in the example, since I don't know any upper bound, and I don't think I can use Ubound in this case, unless I first have it throw all the subkeys into an array, count them and get an upper bound that way. Should I be using a while? c) how do I nest regenumval into Regenumkey so that for each subkey it'll check the values for the one I want? i'm not even sure how to have it search the entries for the specific values, for that matter. Any direction would be greatly appreciated!