Jump to content

Adding Icons To A Tray Menuitem (traycreateitem)


Uten
 Share

Recommended Posts

I want to make a application launcher resting in the tray. When I click the TrayIcon I want to get a menu with the names of the applications and the icons assosiated with the application.

In my case the icon assosiated with the application must be extracted from the executable. It is not found in the registry.

If you use VC to make your programs I the function SHGetFileInfo (in shell32.dll) and friends would give you access to the icons (I belive?). But according to this thread Obtain icon associated with file type, two difficulties "DllCall(... "SHGetFileInfo" ...) will not work due to the structures requiered by the function".

So is there a simple slick autoit way to do this?

EDIT:

I have added a udf, TrayMenuEx to do this. Not a slick way, but sort of a solution in many cases.

Edited by Uten
Link to comment
Share on other sites

  • Moderators

Have you tried just using the exe name?

Example:

$main = GUICreate('main')
GUICtrlCreateIcon(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe', '', 10, 10)
GUISetState()
While 1
    If GUIGetMsg() = - 3 Then Exit
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Have you tried just using the exe name?

Example:

$main = GUICreate('main')
GUICtrlCreateIcon(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe', '', 10, 10)
GUISetState()
While 1
    If GUIGetMsg() = - 3 Then Exit
WEnd
Edit:

After reading your post again, I may be a tad off base :).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Edit:

After reading your post again, I may be a tad off base :mellow:.

Ohh, If you only knew how I wish you were not :)

Do you (or anyone else) know if it is possible to get a handel or pointer to the icon (bmp) used by GUICtrlCreateIcon or set by GUICtrlSetImage?

EDIT: typo

Edited by Uten
Link to comment
Share on other sites

  • Moderators

Ohh, If you only knew how I wish you were not :)

Do you (or anyone else) know if it is possible to get a handel or pointer to the icon (bmp) used by GUICtrlCreateIcon or set by GUICtrlSetImage?

EDIT: typo

If I understand you right just assign it a variable.

$Icon = GUICtrlCreateIcon(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe', '', 10, 10)
Link to comment
Share on other sites

If I understand you right just assign it a variable.

$Icon = GUICtrlCreateIcon(@ProgramFilesDir & '\AutoIt3\AutoIt3.exe', '', 10, 10)
I'm afraid you misunderstod. This will return the controlID and not a pointer to the icon or bmp.

But if I knew how to get a handel to the icon/bmp used by controlID that could possibly be a solution.

Link to comment
Share on other sites

EDIT:

I have added a udf, TrayMenuEx to do this. Not a slick way, but sort of a solution in many cases.

Yupp,

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