Jump to content

Changing trayIcon with internal autoIT ressources - (Moved)


Recommended Posts

Hi,

I am wondering if it is possible to store and access different icon ressource in the AutoIT Exe.

I know that i can make that my app as an icon with :

#AutoIt3Wrapper_icon=Icon.ico

But i would like to have the possibility to change the tray icon depending on the status of the running app...

I know i could simply do it by accessing an external image/icon file, but i would like to use embedded ressources within the EXE if possible.

 

Thank you for your help :)

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

OhBobSaget,

For one of my apps I add the icons to the executable like this:

#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_0.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_1.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_2.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_3.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_4.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_5.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_6.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play_7.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_0.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_1.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_2.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_3.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_4.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_5.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_6.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause_7.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Index.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_File.ico
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_List.ico

And then assign their indices like this:

Global Const $iPlay_Icon = -5, $iPause_Icon = -13, $iIndex_Icon = -21, $iFile_Icon = -22, $iList_Icon = -23

Which allows me use lines like this within the code:

TraySetIcon(@ScriptFullPath, $iPause_Icon - $iIcon_Progress)

TraySetIcon(@ScriptFullPath, $iIndex_Icon)

TraySetIcon(@ScriptFullPath, $iFile_Icon)

I hope that helps.

M23

Edit:

Sorry, the syntax for the directive has changed since I wrote and compiled that. The current version reads:

#AutoIt3Wrapper_Res_Icon_Add=                   ; Filename[,ResNumber[,LanguageCode]] of ICO to be added.
; Add extra ICO files to the resources
; Use full path of the ico files to be added
; ResNumber is a numeric value used to access the icon: TraySetIcon(@ScriptFullPath, ResNumber)
; If no ResNumber is specified, the added icons are numbered from 201 up

So you will need to adjust the assignment statements to match.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

So if i understand correctly :

#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Play.ico,1
#AutoIt3Wrapper_Res_Icon_Add=M:\Program\Au3 Scripts\BMP\Icons\BMP_Pause.ico,2

Then...

Global Const $iPlay_Icon =1, $iPause_Icon =2

Then

TraySetIcon(...)

 

Is that correct ?

Link to comment
Share on other sites

  • Moderators

OhBobSaget,

Close - the icons will be 201 & 202 as explained in the Help file snippet I posted.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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