Jump to content

AutoIT Taskbar icons not disappearing when opened by other program


Recommended Posts

I have an AutoIT script, here it is:

$SEARCH_TERM = 'Pinterest';
$DELAY = 1000; in ms, delay between searches for Pinterest. It can be reduced, but best to not overdo it.

$prevWins = WinList("[CLASS:MozillaWindowClass]");

While (True)
   search();
   Sleep($DELAY);

WEnd

Func getPreviousTitleFromHandle($hnd)
   For $i=1 To $prevWins[0][0]

      $title = $prevWins[$i][0];
      $handle = $prevWins[$i][1];
      If ($handle == $hnd) Then
         Return $title;
      EndIf
   Next


   Return "";
EndFunc

Func search()

   $wins = WinList("[CLASS:MozillaWindowClass]");
   For $i=1 To $wins[0][0]
      ; get window title
      $title = $wins[$i][0];
      If (StringInStr($title, $SEARCH_TERM) <> 0) Then
         $handle = $wins[$i][1];

         ; found pinterest mozilla window
         ;ConsoleWrite('FOUND! ' & $title & @CRLF);
         $prevTitle = getPreviousTitleFromHandle($handle);
         If (StringInStr($prevTitle, $SEARCH_TERM) == 0) Then
            ; previous title doesn't have Pinterest - means navigation took place

            WinActivate($handle);

            $prevWins = $wins;
            Return;
         EndIf
      EndIf
   Next

   $prevWins = $wins;
EndFunc

So I use this script for something, and I also have an AutoHotKey script for something else. And when the Autohotkey script executes it does the following:

- Closes AutoIT script

- Does some actions

- Opens AutoIT script

The problem I have is that every time this takes place (over 24 times per day) the AutoIT icon in the taskbar doesn't disappear.

See photo - https://i.imgur.com/YaRfe5X.jpg

To make the icons go away all I have to do is hover with my mouse on top of them, and they will all go away except the 1 for the script that is currently active.

The person that created me the Autohotkey script told me that I have to edit my AutoIT script and make it not leave an icon in the taskbar if it's closed/opened by a different program. But I don't know how to do that.

Can anyone help?

Thanks

 

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Hey Danyfirex, thanks for responding.

I tried it, but I don't want an icon to not appear in the tray at all. I still want the icon there, so that I can pause it and close it when I have to.

I just don't want the icon to keep doubling up and piling up there (like in the screenshot I shared in my original post) every time the script is closed and opened by my other autohotkeyscript.

Link to comment
Share on other sites

there are scripts for refreshing the tool tray to remove orphaned icons, i have used some in the past that worked but dont remember which one i used.

here is a post containing what you need, i dont know if this one will work for you but it can steer you in the right direction of what to search for.

https://www.autoitscript.com/forum/topic/94447-_refreshtrayicons-_refreshnotificationareaicons-udf-tray-icons-refresh-redux/

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

Hey Alienclone, thanks for answering.

Oh that all looks quite complicated. I'm not a programmer really, so I'm not really good with all the code stuff.

What I'm actually looking to do is implement something either in my existing AutoIT script or my existing AutoHotKey script. I'd rather not have to use a 3rd script only for this.

I wait either for AutoIT to force remove inactive tray icons, or for Autohotkey to shut down the AutoIT script in such a way to where it removes the inactive tray icon.

You think that's possible?

 

Link to comment
Share on other sites

18 hours ago, Scorpys said:

So I use this script for something, and I also have an AutoHotKey script for something else. And when the Autohotkey script executes it does the following:

- Closes AutoIT script

You should do it all within AutoIt. The hotkey killing the PIDs is creating those "left overs". 
Do not kill PIDs, exit as you should. :idea:

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Here one way to achieve it without outside tool :

#NoTrayIcon

Opt("MustDeclareVars", 1)
Global Const $AUTO_OFF = 10 ; auto hide tray icon in secs
Global $hTimer, $bShow = False
HotKeySet ("!0", ToggleShowTray)

While True
  Sleep (100)
  If $bShow And TimerDiff ($hTimer) > $AUTO_OFF*1000 Then ToggleShowTray ()
WEnd

Func ToggleShowTray ()
  $bShow = Not $bShow
  If $bShow Then
    Opt("TrayIconHide", 0)
    $hTimer = TimerInit ()
  Else
    Opt("TrayIconHide", 1)
    $hTimer = 0
  EndIf
EndFunc

The hot key toggle the tray icon.  I also included an auto hide timer, in case user forgets to hide it.  When shown, you can exit normally...

Edited by Nine
Link to comment
Share on other sites

Guys thank you so much for your replies, I really appreciate it :)

It just so happens I asked the guy that created me the Autohotkey script if he can do something about it, and he did a different way of restarting the AutoIT script, and now the problem is no more.

Of course, I'm still testing, so if the problem persists I'll be back to try out the solution mentioned - Nine.

Thanks again :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...