Sign in to follow this  
Followers 0
jfitty

GUI Help

6 posts in this topic

I have a simple GUI interface with a button that runs a function. I have coded this GUI to minimize to the tray when the minimize button is clicked. This works all fine until you run the function. While the function is running I can only minimize it to the taskbar, not to the tray like I want. Is there any way I can make it so that the GUI can still be minimized even when this function is running?

Thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello.

Maybe you should use AdLib functionality?

I.e. run something like

AdlibEnable("Check", 100)

In function called "Check" you will minimize window to tray if it's state = 16.

I think thats must work.

Edited by Crystall

Hello World!

Share this post


Link to post
Share on other sites

I have a simple GUI interface with a button that runs a function. I have coded this GUI to minimize to the tray when the minimize button is clicked. This works all fine until you run the function. While the function is running I can only minimize it to the taskbar, not to the tray like I want. Is there any way I can make it so that the GUI can still be minimized even when this function is running?

Thanks in advance

You could use OnEvent mode and provided your function isn't directly called from an event then you can respond to the minimize button.


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

Heres a snippet of my code (just so you can see how it works):

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#Include <Constants.au3>


Opt('TrayMenuMode', 1)

$TrayRestoreItem = TrayCreateItem('Restore')
TrayItemSetState(-1, $TRAY_DEFAULT)
TrayCreateItem('')
$TrayExitItem = TrayCreateItem('Exit')
TraySetClick(8)

#Region ### START Koda GUI section ### Form=e:\usb backup\backup - good\other\koda form designer\forms\main.kxf
$Form1 = GUICreate("Form1", 395, 191, 192, 124)
$button = GUICtrlCreateButton("Run Function", 16, 152, 104, 19)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUISetState()

While 1
    $TrayMsg = TrayGetMsg()
    Switch $TrayMsg
        Case $TrayRestoreItem
            GUISetState(@SW_SHOW, $Form1)
            GUISetState(@SW_RESTORE, $Form1)
            TraySetState(2)
        Case $TrayExitItem
            ExitLoop
            
        Case $button
            Function()
            
    EndSwitch
    $GUIMsg = GUIGetMsg()
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $Form1 )
            TraySetState(1)
    EndSwitch
WEnd

Where abouts would I put the OnEvent or AdlibEnable? Thanks for the help, I'm just getting going with AutoIt

Share this post


Link to post
Share on other sites

Can anyone give me a hand?

Share this post


Link to post
Share on other sites

I think so.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#include <Constants.au3>


Opt('TrayMenuMode', 1)

Opt("TrayOnEventMode", 1)
Opt("GuiOnEventMode", 1)
$TrayRestoreItem = TrayCreateItem('Restore')
TrayItemSetState(-1, $TRAY_DEFAULT)
TrayItemSetOnEvent(-1, "TrayRestore")
TrayCreateItem('')
$TrayExitItem = TrayCreateItem('Exit')
TrayItemSetOnEvent(-1, "TrayExit")
TraySetClick(8)

#Region ### START Koda GUI section ### Form=e:\usb backup\backup - good\other\koda form designer\forms\main.kxf
$Form1 = GUICreate("Form1", 395, 191, 192, 124)
$button = GUICtrlCreateButton("Run Function", 16, 152, 104, 19)
GUICtrlSetOnEvent(-1, "StartRunFunc")

GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "setToMin")
GUISetOnEvent($GUI_EVENT_CLOSE, "TrayExit")
#EndRegion ### END Koda GUI section ###

GUISetState()
Global $DoRF = False;do the runfunction thing
While 1
    Sleep(10)
    If $DoRF Then
        function()
        $DoRF = False
    EndIf


WEnd

Func TrayExit()
    Exit
EndFunc   ;==>TrayExit

Func TrayRestore()
    ConsoleWrite("restore?" & @CRLF)
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_RESTORE, $Form1)
    TraySetState(2)
EndFunc   ;==>TrayRestore

Func setToMin()
    GUISetState(@SW_HIDE, $Form1)
    TraySetState(1)

EndFunc   ;==>setToMin


Func StartRunFunc()
    $DoRF = True
EndFunc   ;==>StartRunFunc

Func Function()
    For $n = 1 To 1000
        Sleep(300)
        ConsoleWrite($n & @CRLF)
    Next

EndFunc   ;==>Function

You could use OnEvent mode and provided your function isn't directly called from an event then you can respond to the minimize button.

That suggestion and the help file was all that was needed :)

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

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