Jump to content

Recommended Posts

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

  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

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.

Posted

Hi.

Yes it is running.

  On 2/20/2016 at 7:43 PM, Melba23 said:

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

Expand  

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.

  • Moderators
Posted

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:

  Reveal hidden contents

 

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
×
×
  • Create New...