Jump to content

[Solved] TrayIcon double click and secondary click


Simpel
 Share

Recommended Posts

Hi,

I'm wondering why my code snippet isn't working. I copied most of it from a script where it work's. Here is the code:

#include <Constants.au3>

Opt("TrayAutoPause", 0) ; no pause while click
Opt("TrayMenuMode", 1) ; no exit and pause
Opt("TrayOnEventMode", 1); 

While 1
    Sleep(100)
WEnd
Exit

#Region ### START Tray section
Global $hIni = TrayCreateItem("open INI")
TrayItemSetOnEvent (-1, "_INI")
TrayCreateItem("")
Global $hExit = TrayCreateItem("Exit")
TrayItemSetOnEvent (-1, "_Quit")
TraySetState(1)
TraySetClick(16); INI and Exit with secondary click
TraySetOnEvent( $TRAY_EVENT_PRIMARYDOUBLE, "_OpenPath" ); _OpenPath with primary double click
#EndRegion ### END Tray section

Func _OpenPath()
    $sPfad = @ScriptDir
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sPfad = ' & $sPfad & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $iDelimiterPfad = StringInStr($sPfad, "\", 0, -1)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iDelimiterPfad = ' & $iDelimiterPfad & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $sPfadHoeher = StringLeft($sPfad, $iDelimiterPfad)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sPfadHoeher = ' & $sPfadHoeher & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    ShellExecute($sPfadHoeher)
EndFunc

Func _INI()
    ConsoleWrite("_INI" & @CRLF)
    Sleep(10)
EndFunc

Func _Quit()
    Exit
EndFunc

I can see the trayicon but there is nothing happening neither primary double click nor secondary click. What's wrong?

Regards, Conrad

Edited by Simpel
[Solved]
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Moderators

Simpel,

Simple! (pun intended)

You have placed the infinite loop before you create the tray menu - so that code is never run. Just move the loop after the try menu creation lines and all works as you expect.

M23

P.S. You might want to add 8 to your Opt("TrayMenuMode") line - look in the Help file to see why.

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

Ok. Shouldn't code after 8h work in front of a computer. 

I'll try it tomorrow. But I'm sure it will work. Will mark the topic as [Solved] then. 

Thanks and regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

Hi.

Yes it is running.

17 hours ago, Melba23 said:

You might want to add 8 to your Opt("TrayMenuMode") line...

I did this too.

Thank you and regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Moderators

Simpel,

Glad I could help.

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

×
×
  • Create New...