Jump to content

GUI Always On Top


 Share

Recommended Posts

I read around in the FAQ's and some OLD Posts, but i could only find half answers in most of the posts and nothing in the FAQ.

I need an idea on how to get my GUI to stay on top of all windows...

Here is my code

#NoTrayIcon

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Verification For DCS2 Anti-Idle", "Run DCS2 Anti-Idle V3?")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    Exit
EndIf

HotKeySet("^!x", "MyExit")

#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <Constants.au3>

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1) 
;Opt('MustDeclareVars', 1)
Opt("GUICoordMode", 2)

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent")
;TraySetState(2) ; hide --> not needed

dcsgui()

Func dcsgui()
    Local $Button_1, $Button_2, $msg
      GUICreate("DCS2 Anti-Idle", "340", "75")


    $Button_1 = GUICtrlCreateButton("Start Anti-Idle", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("Stop Anti-Idle", 10, -1, 100)
    $Button_3 = GUICtrlCreateButton("End Anti-Idle", 10, -1)

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
            ProcessClose("Anti-Idle(Do Not Run).exe")
                Exit
        Case $msg = $GUI_EVENT_MINIMIZE
                GuiSetState(@SW_HIDE)
                TraySetState(1) ; show
                TraySetToolTip ("DCS2 Anti-Idle V3 - click here to restore")
            Case $msg = $Button_1
                GUICtrlSetState($Button_1, $GUI_DISABLE)

        If Not WinExists("[CLASS:Second Life]") Then
            MsgBox(0, "Error", "Please make sure you have Second Life or Emerald Viewer open before starting the program!")
        Exit
        EndIf

            ControlFocus("[CLASS:Second Life]", "", "")
            WinWait("[CLASS:Second Life]")
            Run("Anti-Idle(Do Not Run).exe", "")
            Case $msg = $Button_2
            ProcessClose("Anti-Idle(Do Not Run).exe")
                  GUICtrlSetState($Button_1, $GUI_ENABLE)
            Case $msg = $Button_3
            ProcessClose("Anti-Idle(Do Not Run).exe")
            Exit
        EndSelect
    WEnd
EndFunc 

Func SpecialEvent()
    GuiSetState(@SW_Show)
    TraySetState(2) ; hide
EndFunc

Func MyExit()
            ProcessClose("Anti-Idle(Do Not Run).exe")
    Exit
EndFunc

Thanks in advance!

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...