Jump to content

Remove Script Paused


Go to solution Solved by BrewManNH,

Recommended Posts

Partial solution:

Opt("TrayAutoPause",0)

For removing use:

Opt("TrayMenuMode",1) ; no default menu (Paused/Exit)

If you want your own tray menu items then use

TrayCreateItem()

TraySetState()

TraySetClick()

and in main loop use TrayGetMsg()

You can look here at my Frame example using it

'?do=embed' frameborder='0' data-embedContent>>

Edited by Zedna
Link to comment
Share on other sites

Thanks. I create a Function that create tray Item but there is a Problem, that when run script and right click on tray icon do't show any thing. Please Guide Me.

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>

Opt("TrayMenuMode",3) ; no default menu (Paused/Exit)

; Functions
Example ()
_CreateTrayItem ()

Func Example ()

$GUI = GUICreate ("Autoit")
GUISetState(@SW_SHOW, $GUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

   ; Delete the previous GUI and all controls.
   GUIDelete($GUI)

  EndFunc

 ; Function for Create custom Tray Item
 Func _CreateTrayItem ()

   Local $TrayExit = TrayCreateItem ("Exit", -1, -1, 1)
   TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

   While 1
      Switch TrayGetMsg()
         Case $TrayExit
            GUIDelete ()
            ExitLoop
      EndSwitch
   WEnd

EndFunc
Link to comment
Share on other sites

That's because the function Example is stuck in an endless loop and the CreateTrayItem function never gets run until you exit the GUI.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Solution

#RequireAdmin
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>

Opt("TrayMenuMode", 3) ; no default menu (Paused/Exit)

; Functions
Example()

Func Example()

    $GUI = GUICreate("Autoit")
    GUISetState(@SW_SHOW, $GUI)
    Local $TrayExit = TrayCreateItem("Exit", -1, -1, 1)
    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        Switch TrayGetMsg()
            Case $TrayExit
                GUIDelete()
                ExitLoop
        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($GUI)

EndFunc   ;==>Example

Use one While loop, check for both GUI and Tray messages within it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Is there a way to just have Exit with no Pause?

Or a way to hide pause?

Pause often confuses people who use my scripts

 

What's wrong with the already presented solutions?

Link to comment
Share on other sites

  • Moderators

Chimaera,

As far as I know you have both the default items or neither - but it is simple to add your own "Exit" trayitem: :)

#include <GUIConstantsEx.au3>

Opt("TrayMenuMode", 1)

$cTrayExit = TrayCreateItem("Exit")

$hGUI = GUICreate("Test", 500, 500)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    Switch TrayGetMsg()
        Case $cTrayExit
            Exit
    EndSwitch
WEnd
Or, as I usually prefer: ;)

#include <GUIConstantsEx.au3>

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

$cTrayExit = TrayCreateItem("Exit")
TrayItemSetOnEvent($cTrayExit, "_Exit")

$hGUI = GUICreate("Test", 500, 500)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _Exit()
    Exit
EndFunc
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...