Jump to content

Remove Script Paused


Go to solution Solved by BrewManNH,

Recommended Posts

Posted (edited)

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
Posted

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
Posted

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!

  Reveal hidden contents

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

Posted
  Quote

i'm Weak in loop and array

 

This has more to do with GUI management.  You should read the GUI Management section in the Help file and Wiki.

kylomas   

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

  • Solution
Posted

#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!

  Reveal hidden contents

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

Posted
  On 11/1/2014 at 8:36 AM, Chimaera said:

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?

  • Moderators
Posted

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:

  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
  • Recently Browsing   0 members

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