Jump to content
Cybazaar

Custom Tray Menu breaks script or vice versa

Recommended Posts

Cybazaar

Umm, hello again.

Ive experimented with creating my own tray menu today and it worked as intended (i followed the example), but when i tried to merge it with the desired script it's not working. If i place the tray menu func first, the Exit option wont work (it will show a MsgBox), or if its last, the script freezes.

This is the Tray Menu script:

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

CustomTray()

Func CustomTray()
    Local $iHelpMSG = TrayCreateItem("Help") ; Help Message
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
    TraySetToolTip("CustomName")

    While 1
        Switch TrayGetMsg()
            Case $iHelpMSG ; Display a message box with the working instructions.
                MsgBox($MB_SYSTEMMODAL, "", "CustomTEXT")

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>CustomTray

 

And this is the script that i want the tray menu implemented in:

#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

HotKeySet("^{F11}", "ExitProg")

Func ExitProg()
    Exit 0 ;;Exits the program
EndFunc

TraySetToolTip("Автоматични Отливка/Матрица/Дата")

MsgBox($MB_SYSTEMMODAL, "", "Използавай знак '+' (плюс) за автоматично попълване на Отливка/Матрица/Дата." & @LF & "" & @LF & "Инструкции:" & @LF & "     1. Програмата работи само за изчакващата отливка" & @LF & "     2. Натискате ПЛЮС след стартирана програма в PCDMIS" & @LF & "      (Когато изпише '№ Отливка')" & @LF & "" & @LF & "За изход се натиска CTRL и F11.")

While 1
   If WinActive ("[TITLE:Input Comment; CLASS:#32770]", "отливка") Then
      If _IsPressed("6B") Then
         WinActivate ("[CLASS:OMain]", "")
         WinMove("[CLASS:OMain]", "", 0, 300, 1280, 702)
         MouseMove (480, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send("{TAB}")
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("{BS}")
         Send ("^v")
         Send ("{ENTER}")
         WinActivate ("[CLASS:OMain]", "")
         MouseMove (480, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send("{TAB 2}")
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("^v")
         Send ("{ENTER}")
         WinActivate ("[CLASS:OMain]", "")
         MouseMove (480, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send("{TAB}")
         Send("+{TAB}")
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("^v")
         Send ("{ENTER}")
      EndIf
   ElseIf WinActive ("[TITLE:Input Comment; CLASS:#32770]", "Отливка") Then
      If _IsPressed("6B") Then
         WinActivate ("[CLASS:OMain]", "")
         WinMove("[CLASS:OMain]", "", 0, 300, 1280, 702)
         MouseMove (650, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("{BS}")
         Send ("^v")
         Send ("{ENTER}")
         WinActivate ("[CLASS:OMain]", "")
         MouseMove (780, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("^v")
         Send ("{ENTER}")
         WinActivate ("[CLASS:OMain]", "")
         MouseMove (480, 770, 0)
         MouseClick ($MOUSE_CLICK_LEFT)
         MouseClick ($MOUSE_CLICK_LEFT)
         Send ("^c")
         WinActivate ("[CLASS:#32770]", "")
         Send ("^v")
         Send ("{ENTER}")
      EndIf
   EndIf
WEnd

Can you tell me where i am doing wrong?

Share this post


Link to post
Share on other sites
Cybazaar

Why is my topic on hold for a review?:(

Share this post


Link to post
Share on other sites
Cybazaar

Can you guys help me out? No matter what i try it's always the same result :(

Share this post


Link to post
Share on other sites
Melba23

Cybazaar,

Quote

Why is my topic on hold for a review?

Probably because your IP has previously been used for spam and so requires a Moderator to approve any posts using the same IP.

And as to your problem - did you put the TrayGetMsg inside the While...WEnd loop like this?

#include <MsgBoxConstants.au3>
#include <Misc.au3>

HotKeySet("^{F11}", "ExitProg")

Opt("TrayMenuMode", 3)

Global $idExit, $iHelpMSG

CustomTray()

While 1
   If WinActive ("[TITLE:Input Comment; CLASS:#32770]", "???????") Then
      If _IsPressed("6B") Then
        ; Code
      EndIf
   ElseIf WinActive ("[TITLE:Input Comment; CLASS:#32770]", "???????") Then
      If _IsPressed("6B") Then
        ; Code
      EndIf
   EndIf

    Switch TrayGetMsg()
        Case $iHelpMSG ; Display a message box with the working instructions.
            MsgBox($MB_SYSTEMMODAL, "", "CustomTEXT")
        Case $idExit ; Exit the loop.
            ExitLoop
    EndSwitch
WEnd

Func CustomTray()
    $iHelpMSG = TrayCreateItem("Help") ; Help Message
    TrayCreateItem("") ; Create a separator line.
    $idExit = TrayCreateItem("Exit")
    TraySetToolTip("CustomName")
EndFunc   ;==>CustomTray

Func ExitProg()
    Exit 0 ;;Exits the program
EndFunc

That works fine for me.

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
Cybazaar

Ah, you've put the switch inside the first While_Wend loop. What i was trying to do was to put them one after another. Yes it now works as intended. Thanks for the help, much appreciated!

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

×