Jump to content

Issue With GUI


kalans
 Share

Recommended Posts

Sorry the title does not explain it much, as I will try to do my best below.

What I Need To Happen:

-Press a button, GUI buttons come up (works fine)

-These buttons will keep displayed until you click outside the GUI area it created (works, not efficiently)

-Clicking the button will display the buttons via GUI again (not working)

The script is below:

Func QuickMenu()
$aWin = WinGetPos($GUI)
$QuickMenu = GUICreate("", 300, 25, -1, $aWin[1] + 50, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($QuickMenu, 0xABCDEF, 255)
$Recipes = GUICtrlCreateButton("Recipes", 0, 0, 75, 25)
$Calcs = GUICtrlCreateButton("Calcs", 75, 0, 75, 25)
$Notes = GUICtrlCreateButton("Patch Notes", 150, 0, 75, 25)
$EditMH = GUICtrlCreateButton("Edit MH", 225, 0, 75, 25)
GUISetState(@SW_SHOW)
While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
   Case $Recipes
    Recipes()
   Case $Calcs
    Calcs()
   Case $Notes
    PatchNotes()
   Case $EditMH
    EditMH()
  EndSwitch
  If Not WinActive($QuickMenu) Then ExitLoop
WEnd
GUIDelete($QuickMenu)
EndFunc   ;==>QuickMenu

So it works fine, and I click outside the given GUI area but when I click the button again to create the GUI (again) it will not display at all. It does not even generate, as it is not in the task tray on the second round. More code available on request, and thank you very much for looking :oops:

Wasn't sure if I should post this here or gen help. PS: $GUI is the default GUI, other GUI names are different and $GUI does not get overwritten.

Edited by kalans
Link to comment
Share on other sites

  • Moderators

kalans,

The function works fine for me - the menu GUI appears and disappears as you say you want: :bye:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

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

$cButton = GUICtrlCreateButton("QM", 10, 10, 80, 30)

GUISetState()

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

Func QuickMenu()
    $aWin = WinGetPos($hGUI)
    $QuickMenu = GUICreate("", 300, 25, -1, $aWin[1] + 50, $WS_POPUP, $WS_EX_LAYERED)
    GUISetBkColor(0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes($QuickMenu, 0xABCDEF, 255)
    $Recipes = GUICtrlCreateButton("Recipes", 0, 0, 75, 25)
    $Calcs = GUICtrlCreateButton("Calcs", 75, 0, 75, 25)
    $Notes = GUICtrlCreateButton("Patch Notes", 150, 0, 75, 25)
    $EditMH = GUICtrlCreateButton("Edit MH", 225, 0, 75, 25)
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $Recipes
                ;Recipes()
            Case $Calcs
                ;Calcs()
            Case $Notes
                ;PatchNotes()
            Case $EditMH
                ;EditMH()
        EndSwitch
        If Not WinActive($QuickMenu) Then ExitLoop
    WEnd
    GUIDelete($QuickMenu)
EndFunc   ;==>QuickMenu

What is different in your script? :oops:

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

Bah, I have $quickmenu and $QuickMenu..The lower case option was a button and the upper was a GUI, change var names and it is good to go! Thank you so much for the help, I was dumbfounded when it was not working >.<

Link to comment
Share on other sites

  • Moderators

kalans,

Always a good idea to use type identifiers with your variables. These are the ones I use to give you an idea:

$a - Array
$b - Binary data. 
$h - Handle, usually to a file or window. NB: AutoIt handled controls return IDs, and so use $c instead.
$c - An AutoIt control Id. 
$i - Integer. 
$f - Boolean. 
$n - Floating point number. 
$s - String. 
$v - Variant (unknown/variable type of data). 
$p - Pointer. 
$t - Structure returned from DllStructCreate. 
$tag - Struct definition string.

No reason to use exactly the same ones, but something along these lines really does help prevent the sort of naming clash you just had. :oops:

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