Jump to content

What am I doing wrong? (


mdb
 Share

Recommended Posts

I can't figure out what I'm doing wrong. I'm totally new to AutoIt and just playing around with making a GUI, I took out a lot of the code I have to get help with this specific issue. I'm not sure if theres any better way to do what I'm trying to do. Basically I just want the thing to exit when I click Exit in the menu, but its just not doing that :(. At first Main() didn't exist, as I tried to do this outside of a Function and it wasn't working. Now inside of one, and it still isn't working. I'm not really sure which way is easier when you get into lengthy programs. Should I even use Select? I tried it without that, and it just wasn't working, so I decided to add it in, and it still isn't working. Even tried to ignore the function and just put 'Exit 0' in there.. Same outcome.

I know someone is going to facepalm and tell me to use search, but I don't even know where to begin.

#include <GuiConstantsEx.au3>
GuiCreate("Test", 280,100)
HotKeySet ("{F1}", "Terminate")

Main()
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func Main()
    $menu = GuiCtrlCreateMenu("Menu")
    $terminate = GuiCtrlCreateMenuItem("Exit",$menu)
EndFunc

Func terminate()
    Exit 0
EndFunc

Thanks a bunch for reading >_<

((Deleted even more garbage coding))

Edited by mdb
Link to comment
Share on other sites

  • Moderators

mdb,

First, welcome to the AutoIt forums.

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here.

As to your code, it just needs a bit of tidying:

#include <GuiConstantsEx.au3>

HotKeySet ("{F1}", "Terminate")

GuiCreate("Test", 280,100)

$menu = GuiCtrlCreateMenu("Menu")
$terminate = GuiCtrlCreateMenuItem("Exit", $menu)

GuiSetState()

While 1

    $msg = GuiGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $terminate
            terminate()
    EndSelect
WEnd

Func terminate()
    Exit 0
EndFunc

Read the Help file, wotk through the tutorials and all will become much clearer! >_<

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