ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Advice needed on AHK script

<< < (6/8) > >>

pilgrim:
I'll let you know the results.

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.

pilgrim:
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?

4wd:
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.-pilgrim (May 13, 2013, 05:40 AM)
--- End quote ---

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?-pilgrim (May 13, 2013, 07:46 AM)
--- End quote ---

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 .....
--- End quote ---

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.

Terminator: Terminate a program that has a SysTray icon

Terminate.exe [/mess] [/context [/test]] [/kill] [/blitz] [/list] <process>
Where: /mess    - sends a WM_CLOSE message to programs window
           /context - opens the programs SysTray context menu and chooses
                          the last entry (usually Exit/Quit)
           /kill       - kill the process and then remove the SysTray
                          icon
           /blitz     - tries everything
           /list       - list processes with SysTray icons
           /test      - opens the icon context menu and selects the
                          last item but doesn't activate it
                          (only valid with /context switch)

The switches can be abbreviated to the first character, ie. /l, /t, /m, /c, /k

If you put multiple methods on the command line it'll only do one in this order: message, context menu and finally kill.

eg. Terminator.exe /kill /context peerblock.exe will use the context menu to try and close peerblock.exe

NOTES:

* Only works with programs that have a SysTray icon
* Only works with programs that don't open a modal requester, (currently), ie. "Are you sure?"
* Not sure if it will work for the hidden icon area in Vista+
So in your case you could try:

terminator.exe /m d4.exe
terminator.exe /m networkindicator.exe
terminator.exe /c peerblock.exe
terminator.exe /c sbiectrl.exe

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  :D

UPDATE:

* Tries sending WM_CLOSE 5 times at 5ms intervals, (the Pilgrim factor)
* Added /blitz option
Source added to archive 20130523

pilgrim:
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.-4wd (May 15, 2013, 09:51 PM)
--- End quote ---

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?
   WM_MOUSEMOVE := 0x200

   ControlGetPos, xTray,, wTray,, ToolbarWindow321, ahk_class Shell_TrayWnd
   endX := xTray + wTray
   x := 5
   y := 12

   Loop
   {
      if (x > endX)
         break
      point := (y << 16) + x
      PostMessage, %WM_MOUSEMOVE%, 0, %point%, ToolbarWindow321, ahk_class Shell_TrayWnd
      x += 18
   }
--- End quote ---

I am attaching the tray cleaning program .....
--- End quote ---

Doesn't do a thing here, exits immediately.
--- End quote ---

Now that does surprise me because I have it working on both 7 and XP.
The complete script reads as follows:

rem Check if our flag file exists and act accordingly
if exist internet_is_on.txt goto running

rem Turning Internet items ON
echo hah>internet_is_on.txt

start /D "C:\Program Files (x86)\D4" D4.exe
start /D "C:\Program Files (x86)\Sandboxie" SbieCtrl.exe
start /D "C:\Program Files (x86)\PeerBlock" peerblock.exe
start /D "C:\Program Files (x86)\network-activity-indicator" NetworkIndicator.exe

netsh interface set interface "Router Connection" ENABLED

goto alldone

:running
rem Internet is ON, turn it all OFF now
del internet_is_on.txt

taskkill /F /IM peerblock.exe
taskkill /F /IM SbieCtrl.exe
taskkill /F /IM D4.exe

netsh interface set interface "Router Connection" DISABLED

netsh interface set interface "OpenVPN Adapter" DISABLED

rasdial /disconnect

Taskkill /F /IM NetworkIndicator.exe

start /d "C:\Program Files (x86)\Refresh Tray" RefreshTray.exe

:alldone
--- End quote ---

I'll give the new version of Terminator a run and let you know.
Just out of curiosity where do you put the exe, in the same folder as the batch file, System32?

I'm sure one of the other programmers here could come up with something a lot nicer  :D
--- End quote ---

Nice is good, efficient is better. :)

4wd:
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.-4wd (May 15, 2013, 09:51 PM)
--- End quote ---

I just tried manually moving the cursor over the USB SR icon and a 400ms delay seems about right.-pilgrim (May 16, 2013, 04:51 AM)
--- End quote ---

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?
--- End quote ---

That's a question for our AHK specialists  ;)

I'll give the new version of Terminator a run and let you know.
--- End quote ---

Assuming it might work:


--- Code: Text ---netsh interface show interface "Router Connection" | find /i "disabled" >NULif errorlevel 1 goto running rem Turning Internet items ONstart /D "C:\Program Files (x86)\D4" D4.exestart /D "C:\Program Files (x86)\Sandboxie" SbieCtrl.exestart /D "C:\Program Files (x86)\PeerBlock" peerblock.exestart /D "C:\Program Files (x86)\network-activity-indicator" NetworkIndicator.exe netsh interface set interface "Router Connection" ENABLED goto alldone :runningrem Internet is ON, turn it all OFF nowterminator.exe /c peerblock.exeterminator.exe /c SbieCtrl.exeterminator.exe /m D4.exe netsh interface set interface "Router Connection" DISABLED netsh interface set interface "OpenVPN Adapter" DISABLED rasdial /disconnect terminator.exe /m NetworkIndicator.exe :alldone
Just out of curiosity where do you put the exe, in the same folder as the batch file, System32?
--- End quote ---

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).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version