Jump to content

Recommended Posts

Posted

I often have a few AutoIt scripts running at once and, partially out of laziness, they all have the same icon which is a bit confusing. Normally, I only need to see a single script that I use to launch other scripts/programs/etc. I'd like to move all of the "extra" scripts to the hidden icons section, however if I drag a single icon, they all move to the hidden section.

After looking at the documentation for Shell_NotifyIcon, it looks like this might be an undocumented feature of using the same window handle for each AutoIt script's icon... in this case it's likely the AutoItWindow. My first thought was to update each icon to have a different window handle. The NotifyIconDataA structure requires a uID to update the tray icon and I couldn't find a way to obtain this information without creating the tray myself.

Is there a way to find the uID of the NotifyIconDataA structure that is created by AutoIt?

My second thought was to make a UDF around Shell_NotifyIcon and make trays myself. Has anyone else created something similar (I couldn't find any) or should I start making one?

In the meantime, I'll start making some icons (ew)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted

Hello @seadoggie01.  :)

Not exactly sure where you are heading with this.   Why Tray* functions do not suffice ?
Maybe providing a snippet of the non-working code could help to understand your issue.

FYI, tray icon uID of AutoIt hidden window is 1.  See :

#include <WinAPIShellEx.au3>

Local $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)
DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA))
DllStructSetData($tNOTIFYICONDATA, 'hWnd', WinGetHandle(AutoItWinGetTitle()))
DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON)

Sleep(1000) ; show icon for one sec

DllStructSetData($tNOTIFYICONDATA, 'ID', 1)
_WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) ; delete current tray icon of running script

Sleep(10000)

 

Posted
31 minutes ago, Nine said:

Not exactly sure where you are heading with this.

He wants to have scripts to show icons independently as if from different executables so that scripts are not treated as if from the same executable, as they obviously are.
I guess a full "Notifications and the Notification Area" UDF

I think that is worth it.

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

Posted

@Nine If you run two scripts at once, you're not able to move just one of the tray icons to the "Show hidden icons" section of the Taskbar. I have a few scripts that run in the background that I'd like hidden, but another script that I don't want hidden.

If the uID is 1, then I think that should solve my problem... I want to update the window handle associated with the tray icons because that will (I think) allow them to be split. I'll try this out in the morning :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
43 minutes ago, seadoggie01 said:

If you run two scripts at once, you're not able to move just one of the tray icons to the "Show hidden icons" section

True

43 minutes ago, seadoggie01 said:

I have a few scripts that run in the background that I'd like hidden

Just create a main icon menu accordingly, for each scripts you started, add a possibility to cancel them ?

46 minutes ago, seadoggie01 said:

If the uID is 1, then I think that should solve my problem...

Well, I still do not fully understand the final objective of your issue.  But I am glad that I could help.

Posted
21 hours ago, Nine said:

Just create a main icon menu accordingly, for each scripts you started, add a possibility to cancel them ?

image.png.f8f0adc744bd2c8d950e1f9e7db2b462.png
Yes, but this gets confusing quickly. I don't usually have this many, but I'd still like to hide some of them ;)

After trying some things, either I'm doing this wrong or it won't work. I thought that instead of sending $NIM_DELETE I could pass $NIM_MODIFY and change the window handle. However that call fails probably due to this...

Quote

The Shell uses either (hWnd plus uID) or guidItem to identify which icon to operate on when Shell_NotifyIcon is invoked.

Even when creating an icon through the WinAPI with a different hWnd, GUID, and Id, Windows still groups the AutoIt icons together. My new theory is that it's checking the executable requesting the icon and grouping them that way. Tomorrow I'll try testing with a copy of the AutoIt executable.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted

All these
   image.png.baafe8e5f61411bd0ee9df46a5874e04.png       image.png.625802421cbb5a3256c533e09dbd947d.png     image.png.90ae2450915c824fbcb92934e4b92ad8.png   etc.

are scripts, and if I drag one, all of them move ( as seen above ). But I do want to have them there in the tray on display. They change colors/icons on events.
Maybe you can make yourself a script that will show the tray icon or hide them ( so yes, one more tray icon to hide/show your other script icons ).
I make scripts that have the icon hidden but if run it again, it'll show the icon ( via IPC telling the preexisting script to do it ).

The simplest solution for what you say you'd like to have is to compile them

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

Posted (edited)

to test it I made a folder
"C:\Program Files (x86)\AutoIt3.of"
and inside it I copied AutoIt3.exe, AutoIt3_x64.exe and the Include folder

then I made a folder on the D:\ where I usually make my scripts
and I made the files _TestIcon.au3,
and test.au3 which I ran to see what happened

; _TestIcon.au3
#include <GUIConstantsEx.au3>
#include <AutoItConstants.au3>
#include <WinAPIShellEx.au3>

Global $g_Name, $g_iID = 0

If $CmdLine[0] > 0 Then
    If StringIsDigit($CmdLine[1]) Then $g_iID = Int($CmdLine[1])
EndIf

$g_Name = StringStripWS(StringTrimRight(@ScriptName, 4) & "_v" & $g_iID, 8)
_WinAPI_SetCurrentProcessExplicitAppUserModelID($g_Name)

TraySetIcon("shell32.dll", 10 + $g_iID)
TraySetToolTip($g_Name)
Opt("TrayAutoPause", 0)

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate($g_Name, 300, 200)
    GUISetIcon("shell32.dll", 10 + $g_iID)
    Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idButton_Close
                ExitLoop
        EndSwitch
    WEnd

    ; Clean up
    GUIDelete($hGUI)
EndFunc   ;==>Example

 

; test.au3

Local $Cmd = '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\_TestIcon.au3"'
ConsoleWrite("$Cmd=" & $Cmd & @CRLF)

Local $CmdOf = '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\_TestIcon.au3"'
$CmdOf = StringReplace($CmdOf, "\AutoIt3\", "\AutoIt3.of\")
ConsoleWrite("$CmdOf=" & $CmdOf & @CRLF)

Run($CmdOf & ' 1')
Run($CmdOf & ' 1')

Run($Cmd & ' 2')
Run($Cmd & ' 2')

Run($CmdOf & ' 3')
Run($Cmd & ' 4')


( .of from the overflow )

Edited by ioa747

I know that I know nothing

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
  • Recently Browsing   0 members

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