Author
Topic: Advice needed on AHK script (Read 13580 times)

Something I noticed yesterday which has probably been going on all the time is that my Windows 7 PC and my Netbook (XP) both have programs that produce pop-ups when you hold the cursor over the tray icons, on 7 it is USB Safely Remove, on XP it is Battery Monitor, when I run any of the tray cleaning programs the pop-ups appear.

I am attaching the tray cleaning program I put together from the AHK script for you to try if you want to, this morning I tried variations of it by reducing the number of times the script repeats, (the default is 4) I found that 3 repeats is also removing all the icons but any less and some get left behind. I have left it at 4 to give it a bit of leeway.

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.

After fairly extensive testing I have found that the pop-ups I mentioned are no longer appearing with CleanTray, and with 4 programs running, Network Activity Indicator being the fourth, these are the results:

no switch: leaves 1 or more icons/once: only removed 1 icon/debug /once: worked perfectly/m: worked perfectly

However, if I am running a PPTP VPN (i.e. using PPTPchek) the last 2 switches both leave 1 icon behind, not necessarily the same one each time.Running the OpenVPN Adapter seemed to make no difference but then it doesn't have its own icon.As far as I could tell none of the above rearranged any icons.

Although I know it's not you usual program of choice I am wondering if it is possible to prevent the pop-ups appearing when using the AHK script?

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.

Something I noticed yesterday which has probably been going on all the time is that my Windows 7 PC and my Netbook (XP) both have programs that produce pop-ups when you hold the cursor over the tray icons, on 7 it is USB Safely Remove, on XP it is Battery Monitor, when I run any of the tray cleaning programs the pop-ups appear.

OK, at this point you should de-fiddle your system because those things don't appear unless the mouse has been over the target icon for at least 400ms by default, so this implies you've dropped the delay to almost, (if not), 0.

I've set mine to 30ms and they don't appear, CleanTray moves the mouse at the fastest speed AutoIt can which takes less than 10ms to traverse an area the width of your SysTray three times. With the /debug switch it takes ~1.5 seconds to do it.

Add to the fact that to remove 4 icons it will do a total of 5 cycles, that's 15 runs in total over that area in less than a second.

Your icons are about 24x24 pixels by the looks, (tray height of 28), a total of about 26 icons: 630 pixels in ~3ms / 26 = ~0.11ms per icon.

Even with the /debug switch it's ~20ms per icon.

I set my taskbar the same, (as close as possible), a single row at the bottom with about 28 notification icons, and 4-6 orphaned at the left - in every case CleanTray worked no matter where the taskbar was located, (top, bottom, left, right), or whether it's hidden or not, (provided the icon had no background process).

I am attaching the tray cleaning program .....

Doesn't do a thing here, exits immediately.

Addendum: Since you said Terminator worked for both D4 and NAI I've been playing with it a bit more and you can try this version out.

It doesn't do anything that's OS unfriendly, (/k does the same thing as taskkill), tested it here on Win7 on various tray dwelling programs, (but only for D4, NAI and PeerBlock in your specific case), and it seemed to work OK - system didn't crash, all my drives still seem to be full of junk.

I'm sure one of the other programmers here could come up with something a lot nicer

OK, at this point you should de-fiddle your system because those things don't appear unless the mouse has been over the target icon for at least 400ms by default, so this implies you've dropped the delay to almost, (if not), 0.

I just tried manually moving the cursor over the USB SR icon and a 400ms delay seems about right.Looking at the basic script I started from the only figure that I can see that could relate to a delay is the 200?

OK, at this point you should de-fiddle your system because those things don't appear unless the mouse has been over the target icon for at least 400ms by default, so this implies you've dropped the delay to almost, (if not), 0.

Well, in that case I'm stumped as to why you'd be getting the tooltips appearing so quick, I've got Zentimo running and it's menu doesn't appear unless the mouse is stationary over the icon, (or moving very slowly - far slower than CleanTray moves it).

At this point because I can't replicate exactly what you're seeing on any of my machines, (XP x86, Win7 x64, Win8 x86, WHS2011 x64), I'll have to say there's not much more I can do with CleanTray unless someone else can provide a bit more insight.

Looking at the basic script I started from the only figure that I can see that could relate to a delay is the 200?

Just out of curiosity where do you put the exe, in the same folder as the batch file, System32?

Anywhere in a path or call it with the full path to it, if it was me I'd try to keep all "foreign" files out of System32 and just put it in the same directory as the batch files, (which you might need to add to the system path).

I tried the latest version of Terminator using the script you posted above and putting the EXE in the same folder.Once again I'm afraid the results were inconsistent, the very first time it shut down everything, after that it left anything from 1 to 3 programs running.I made the alterations before I did anything else so the first time it was run was the first time it was connected to the internet after being turned on today.

NAI closed nearly every time, D4 closed the majority of times, either one or both of the other two were always left running.

The only remaining possibility I can think of is a clash with something else I have running.

I have taken the first part of your script and modified my batch file so it no longer creates a flag file.

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.

Question 1) Is it possible to hide the cursor from showing over the icons?Question 2) Is it possible to create Terminator2 that leaves out NAI (not needed on XP)?Question 3) When you've answered question 1 any chance of a copy of the code so that I can see if I can translate it into AHK?Question 4) I can edit the 2 AHK programs I put together with Resource Hacker, that doesn't work with Terminator (with the exception of the icons), would that be true of all AutoIt programs?

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.

There must be some strange timing issues on your computer, (which don't seem to appear on any of mine), for /m not to work with D4 and NAI occasionally.

Question 1) Is it possible to hide the cursor from showing over the icons?

The cursor is moved over the icon so Windows can remove it, then it gets put back in it's original position, (at least I think I put that part in = I'll check when I wake up).

EDIT: Yep, it's in there - the mouse moves back to wherever it started before the program was invoked.

Are you saying that the mouse stays over the tray icon position after it's already killed the program?

If so, this might be the cause of the inconsistent results with CleanTray/Terminator - something eating mouse movements or the system being abnormally slow to respond, (although I can't think of much that's slower than my Win8Pro Atom N270 netbook with a 4200RPM HDD ).

Question 2) Is it possible to create Terminator2 that leaves out NAI (not needed on XP)?

Um, can't you just not have that line in your batch file?

Question 3) When you've answered question 1 any chance of a copy of the code so that I can see if I can translate it into AHK?

Can't wait to see that When I've cleaned up the code a bit.

Question 4) I can edit the 2 AHK programs I put together with Resource Hacker, that doesn't work with Terminator (with the exception of the icons), would that be true of all AutoIt programs?

I have no idea, Terminator was compiled as a CLI program, wasn't designed to be run from the Windows interface.

/m won't work on PeerBlock/SandBoxie because they won't allow other programs to close them, (security measure I presume), therefore it's context menu or just kill them.

No, it was purely cosmetic so that you do not actually see the icon moving.

Yes...well, given your systems fussiness towards things that are too fast....it's set at the second fastest setting. At the fastest, the mouse gets teleported to the position - exactly what CleanTray does but your system didn't like that.

Oh, forgot, can you try Terminator.exe /c on PeerBlock/SandBoxie again - added a couple of small, (5ms or so), delays into the mix.

No, it was purely cosmetic so that you do not actually see the icon moving.

That was meant to be the cursor, not the icon. I was wondering if the cursor could be hidden when it was moving?

CleanTray: Appears to be working without problems.

Terminator: Went back to your script above (Reply 29) and it shut everything down except Peerblock. I just changed that to /b and left the rest as it was, it worked. As it was working I never tried any of the other combinations of switches.

Each of the above was tried at least a dozen times.

I tried adding a PPTP VPN to both of the above and got some interesting results.I tried it with CleanTray and PPTPchek shut down every time. I then tried it with Terminator and it hung, went back to CleanTray and it was hanging with that as well.From then on it was hanging more often than not with both programs.I know we have a separate thread for PPTPchek but I thought it worth mentioning here as it relates to testing the other two programs.

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.

Also, if Terminator works there shouldn't be a need for CleanTray to be run, soooo, having the VPN disconnection first might be enough of a delay such that by the time Terminator runs, PPTPchek has already exited because the VPN no longer exists.

There is actually a madness to my method. (Or should that be the other way round?)

The start commands are in the order the icons are arranged in the tray, right to left from the top.The terminate commands are in reverse order except for NAI, the reason for that is because in the short time it takes for everything to shut down it gives the NAI icon time to indicate that the main connection has been disabled, it greys out.I agree that the disconnect/disable commands needed rearranging as the main connection should have been last.

Until now I have still been using taskkill and RefreshTray as I have tried so many variations of programs I wanted to be able to fall back each night on one that I knew was working.

I tried various modifications on the existing RefreshTray script to stop the pop-up from opening but nothing worked, so if there is an answer in AHK it looks like it needs an extra command.I found that USB SR has an option to disable mouse-over for its pop-up but that means it needs to be activated manually and once it opens it stays there until I close it manually, no point.

I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.I've not had to try since.