Simpel

[Solved] TrayIcon double click and secondary click

5 posts in this topic

#1 ·  Posted (edited)

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]

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites



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.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
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


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   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.

Share this post


Link to post
Share on other sites

Simpel,

Glad I could help.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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

  • Similar Content

    • Simpel
      By Simpel
      Hi, I created a gui with date field but formatted as time in HH:mm. It always shows "now-time". Even if I try to set it with GUICtrlSetData.
      #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT) ; to select a specific default format Local $sStyle = "HH:mm" ; Just display hours and minutes <<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ConsoleWrite(GUICtrlRead($idDate) & @CRLF) GUICtrlSetData($idDate, "00:00") ConsoleWrite(GUICtrlRead($idDate) & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example How can I set the time field with another time and how can this field be set blank?
      Regards, Conrad
    • hunte922
      By hunte922
      Edit: The solution! Maybe?
       
      I need to download an image from a website using AutoIt but the download, when viewed in a text editor, does not appear to be the same as if I had downloaded it from a web browser.
      Could anyone help me figure out why this is happening?
      I've already tried _INetGetSource, InetGet, _IENavigate, wget, this, and a few .bat and .vbs scripts.
       
      Example Code:
      #include <Inet.au3> Local $source = _INetGetSource("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a") Local $newfile = FileOpen(@ScriptDir & "\test.txt", 2) FileWrite($newfile, $source) FileClose($newfile) Image URL: http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a
      Screenshot attached.

    • TommyDDR
      By TommyDDR
      Hi,
      I have to set a resizing mode to differents controls in a hidden gui, that gui is initialised (hidden) and resized by a WinMove.
      But when i show it, control are not resized where thez should.
      There is a simple code that reproduce the problem.
      Same gui, same content, one displayed then moved, the other moved then displayed :
      #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) Global $gui[2] Global $labels[2] Global $taille[2] = [200, 100] For $i = 0 To UBound($gui, 1) - 1 $gui[$i] = GUICreate($i, $taille[0], $taille[1], $i * ($taille[0]+100) + 500, (@DesktopHeight-$taille[1])/2) GUISetOnEvent($GUI_EVENT_CLOSE, "quit", $gui) $labels[$i] = GUICtrlCreateLabel("Test resizing...", $taille[0]-105, $taille[1]-25, 100, 20) GUICtrlSetBkColor($labels[$i], 0xE0E0E0) GUICtrlSetResizing($labels[$i], BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) Next GUISetState(@SW_SHOW, $gui[0]) For $i = 0 To UBound($gui, 1) - 1 WinMove($gui[$i], "", Default, Default, $taille[0]+100, $taille[1]+100) Next GUISetState(@SW_SHOW, $gui[1]) While(True) Sleep(10) WEnd Func quit() Exit EndFunc Is that a bug or do miss i something ?
      EDIT : This bug disapear if gui is shown at lease one time (even if hide then)
    • echoAwoo
      By echoAwoo
      SOLVED
      Basically, my script needed a conditional assignment to a variable. It needed to check if the size of the array was valid before assigning any value to the variable.
       
       


      So I've got a data entry task that I've been trying to automate. I actually have the script running, it cycles, draws it's necessary arrays, etc. But it will only cycle up to count #22, 23+ do not work.
      THE GIST
      I have two excel documents that I draw the data from. $aWO array has values from one of these documents. The instructions to draw these are under _at_wo().
      This function feeds into another function to compare a derived value from the first file and request it's corresponding value. In order to do this, I used _Excel_RangeFind() (had to comment out the Cell Name and Cell Comment aspects of that function in order for it to work at all.) Then I pull the address information from array $aTracking[0][2], swap the column from A to B, and it works beautifully. 
      Then cycle 23 happens, and then $aTracking[0][2] reports as out of range. Why? 
       
      Here's the code. Error reported from line #70. This array call works on loops 1-22 ($iCount value 0-21)
      http://pastebin.com/Bd5v6Dbc
    • lgvlgv
      By lgvlgv
      I have a problem with changeing the trayicon while program is running, is it possible?
      my script seems to be running for a while then it becomes unresponcive
       
      I have a script thats sets the tray icon to a "red icon" when i lose ping connection, then when ping resumes it sets it back to green icon.
      But for some reason the script gets unresponsive and nothing happens, there are no errors just have to kill the trayicon the hardway.
      Some times it can run for hours before it starts to "hang" again.
      $nTrayIcon1 = _TrayIconCreate("Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2, @ScriptFullPath, -1)
       
      Local $iPing = Ping($LatencyUrl, $LatencyMS) If @error Then If @error = 1 Then _DebugOut("---------- (_Ping Start)-----------") _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5) _TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & _GetGatewayIP() & @CRLF & " Internet error: " & @error & ", Host is offline.") ; _TrayTip($nTrayIcon1, "Lost Connection", "Error: " & @error & " Host is offline.", $nTimeOut = 3, $nInfoFlags = 0) _DebugOut("*PING: " & @error & ", Host is offline") _DebugOut("---------- (_Ping End)-----------" & @CRLF) ElseIf @error = 2 Then _DebugOut("---------- (_Ping Start)-----------") _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5) _TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & _GetGatewayIP() & @CRLF & " Internet error: " & @error & ", Host is unreachable.") ; _TrayTip($nTrayIcon1, "Lost Connection", "Error: " & @error & "Host is unreachable.", $nTimeOut = 3, $nInfoFlags = 0) _DebugOut("*PING: " & @error & ", Host is unreachable") _DebugOut("---------- (_Ping End)-----------" & @CRLF) ElseIf @error = 3 Then _DebugOut("---------- (_Ping Start)-----------") _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5) _TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & _GetGatewayIP() & @CRLF & " Internet error: " & @error & ", Bad destination") ; _TrayTip($nTrayIcon1, "Lost Connection", "Error: " & @error & " Bad destination.", $nTimeOut = 3, $nInfoFlags = 0) _DebugOut("*PING: " & @error & ", Bad destination") _DebugOut("---------- (_Ping End)-----------" & @CRLF) ElseIf @error = 4 Then _DebugOut("---------- (_Ping Start)-----------") _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -5) _TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & _GetGatewayIP() & @CRLF & " Internet error: " & @error & ", Other errors") ; _TrayTip($nTrayIcon1, "Lost Connection", "Error: " & @error & " Other errors.", $nTimeOut = 3, $nInfoFlags = 0) _DebugOut("*PING: " & @error & ", Other errors") _DebugOut("---------- (_Ping End)-----------" & @CRLF) EndIf Else _DebugOut("*PING: The roundtrip-time took: " & $iPing & "ms.") _TrayIconSetIcon($nTrayIcon1, @ScriptFullPath, -1) _TrayIconSetToolTip($nTrayIcon1, "Datornamn: " & @ComputerName & @CRLF & "IPAdress: " & @IPAddress1 & " ," & @IPAddress2 & @CRLF & "Gateway: " & _GetGatewayIP() & @CRLF & " Internet: " & $iPing & " Ms.") ; _TrayTip($nTrayIcon1, "Internet Access", "Internet: " & $iPing & " Ms.", 3, 0) _DebugOut("---------- (_Ping End)-----------" & @CRLF) EndIf