Sign in to follow this  
Followers 0
Zomp

Why does TrayGetMsg() pause the script?

5 posts in this topic

#1 ·  Posted (edited)

I'm writing a script where I use the TrayGetMsg() function to check if the user clicks on some item in the system tray menu.

Moreover, I have set the AdLibEnable function so that every 250 milliseconds a tooltip informs me about the passed time.

So, I have recognized that if the user clicks on the system tray, opening the system tray menu but without choosing any item in the menu, the script pauses since the adlib function is no more executed.

Am I wrong?

Is there any method to NOT make the script pause when the system tray menu remains opened?

Thanks for your help.

Edited by Zomp

Share this post


Link to post
Share on other sites



I'm writing a script where I use the TrayGetMsg() function to check if the user clicks on some item in the system tray menu.

Moreover, I have set the AdLibEnable function so that every 250 milliseconds a tooltip informs me about the passed time.

So, I have recognized that if the user clicks on the system tray, opening the system tray menu but without choosing any item in the menu, the script pauses since the adlib function is no more executed.

Am I wrong?

Is there any method to NOT make the script pause when the system tray menu remains opened?

Thanks for your help.

Look up AUtoItSetOption, and see the option TrayAutoPause

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Look up AUtoItSetOption, and see the option TrayAutoPause

Sorry, I have forgotten to specify that I have already set
Opt("TrayAutoPause", 0)
.

Here is another guy that seems to have the same problem and nobody has solved it yet:

http://www.autoitscript.com/forum/index.ph...aygetmsg++pause

Edited by Zomp

Share this post


Link to post
Share on other sites

Sorry, I have forgotten to specify that I have already set

Opt("TrayAutoPause", 0)
.

Here is another guy that seems to have the same problem and nobody has solved it yet:

http://www.autoitscript.com/forum/index.ph...aygetmsg++pause

Same answer as posted there:

I think you are only demonstrating a "feature" of the Windows API. If I open any tray menu with Explorer up, F5 will not update either. While the desktop is focused on a tray menu, I don't think any hot keys outside of the tray menu's are active.

Cleaned up demo:

HotKeySet("^m", "DisplayMsgAndExit")

Opt("TrayMenuMode", 1); Default tray menu items will not be shown.
Opt("TrayAutoPause", 0); 0 = No Pause
$exititem = TrayCreateItem("Exit")
TraySetState(); Show the tray icon

While 1
    If TrayGetMsg() = $exititem Then Exit
WEnd

Func DisplayMsgAndExit()
    MsgBox(0, "TrayAutoPause", "TrayAutoPause working", 5)
EndFunc  ;==>DisplayMsgAndExit

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I'm writing a script where I use the TrayGetMsg() function to check if the user clicks on some item in the system tray menu.

Moreover, I have set the AdLibEnable function so that every 250 milliseconds a tooltip informs me about the passed time.

So, I have recognized that if the user clicks on the system tray, opening the system tray menu but without choosing any item in the menu, the script pauses since the adlib function is no more executed.

Am I wrong?

Is there any method to NOT make the script pause when the system tray menu remains opened?

Thanks for your help.

@Zomp

use the timers udf as a workaround

#include <Timers.au3>

Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
Opt("MustDeclareVars", 1)

Local $hGUI, $Msg, $Msgitem, $Exititem, $tToolTipTime
$hGUI = WinGetHandle(AutoItWinGetTitle()) ; for non-gui app, otherwise use handle returned by GuiCreate()
If (Not IsHWnd($hGUI)) And MsgBox(0, "", "Invalid GUI handle", 5) Then Exit 
$tToolTipTime = _Timer_SetTimer($hGUI, 250, "_ToolTipTime")
$Msgitem = TrayCreateItem("Msg")
$Exititem = TrayCreateItem("Exit")
TraySetState()

While 1
    $Msg = TrayGetMsg()
    Switch $Msg
        Case $Msgitem
            MsgBox(0, "", "Tooltip still working", 5)
        Case $Exititem
            Exit
    EndSwitch
WEnd

Func _ToolTipTime($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    Beep(1000,5)
    ToolTip("Current Time", @DesktopWidth /2, @DesktopHeight /2, @HOUR &":"& @MIN &":"& @SEC)
EndFunc   ;==>_ContextMenu

Func OnAutoItExit()
    ToolTip("")
    _Timer_KillTimer($hGUI, $tToolTipTime)
EndFunc

I see fascists...

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
Sign in to follow this  
Followers 0