Jump to content

[SOLVED] [GUI] What files to include?


Recommended Posts

Hello,

I'm reading the GUI chapter in O'Reilly's AutoIt v3: Your Quick Guide by Andy Flesner, and am stuck at compiling its very first GUI sample.

Here's the error I get when choosing Tools > Compile:

C:\gui1.au3(18,67) : WARNING: $SS_CENTER: possibly used before declaration.

GUICtrlCreateLabel("Just some label", 50, 180, 300, 15, $SS_CENTER)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\gui1.au3(25,9) : ERROR: syntax error

OnEvent mode

~~~~~~~~^

C:\gui1.au3(18,67) : ERROR: $SS_CENTER: undeclared global variable.

GUICtrlCreateLabel("Just some label", 50, 180, 300, 15, $SS_CENTER)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\gui1.au3 - 2 error(s), 1 warning(s)

!>10:41:56 AU3Check ended.rc:2

>Exit code: 0 Time: 12.872

Here's my code:

#include <GuiConstants.au3>

Func click()
    GUISetState(@SW_HIDE)
    Exit
EndFunc

Func GUIExit()
    Exit
EndFunc

Opt('GUIOnEventMode', 1)

GuiCreate("My very first GUI", 400, 300)

GUISetOnEvent($GUI_EVENT_CLOSE, 'GUIExit')

GUICtrlCreateLabel("Just some label", 50, 180, 300, 15, $SS_CENTER)

GUICtrlCreateButton("Click me", 100, 210, 200, 30)
GUICtrlSetOnEvent(-1, 'click')

GUISetState(@SW_SHOW)

OnEvent mode
While 1
    Sleep(500)
WEnd

Apparently, a GUI in AutoIT requires more than just GuiConstants.au3, but I don't know what other files I need. Does someone know?

BTW, in Scite, in the Tools menu, what's the difference Compile and Build?

Thank you.

Edited by littlebigman
Link to comment
Share on other sites

For those having the same issue: The O'Reilly was published in 2007, and AutoIT has gone through changes since then which broke some scripts, even basic ones like the one presented in the book.

To find in which include file some constant has been declared, you'll have to grep for the string in the .\Include\ directory.

Also, it appears that the "OnEvent mode" command right before the While/Wend eternal loop is no longer used:

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include  <StaticConstants.au3>

...

;OnEvent mode
While 1
    Sleep(500)
WEnd

HTH,

Edited by littlebigman
Link to comment
Share on other sites

  • Moderators

littlebigman,

You will save your self a lot of trouble if you run through the tutorials I told you about yesterday - you will then not post nonsense like: :)

it appears that the "OnEvent mode" command right before the While/Wend eternal loop is no longer used

Go and look in the Help file under <GUI Reference> and you will see that OnEvent mode is very much alive and kicking - it is one of the 2 modes in which you can run AutoIt.

Of the 2 tutorials (which in case you lost the links are here and here), "Learning to Script with AutoIt3" is much more up-to-date than the book you are reading - I would recommend leaving this obviously out-dated book to one side until you get a better grip on current AutoIt syntax. The second, "AutoIt 1-2-3" is actually a series of files which you run from within SciTE to see the various functions of AutoIt working - you do not have to study the files themselves as you thought in your other topic, although it will do no harm once you are a bit more experienced. ;)

I would also recommend reading the first few sections of the Help file carefully. ;)

As to your specific questions:

- There is no need to grep in the Include folder - the type of constant you are missing is usually enough to give you a hint about which Include file you need. For example, $SS_CENTER is a contant from StaticConstants, anything with $WS comes from WindowsConstants, etc. You will soon get the hang of it. :)

- You do not need to tell SciTE where AutoIt is - if you carried out a normal install, SciTE installs itself in the AutoIt folder and everything knows where everything else is automatically.

- Using "Compile" in the SciTE menu runs the compiler on the current script via a dialog where you can set many of the compilation options. "Build" runs the compiler directly using any directives you have in the script to set anything other than the default compilation options.

Keep at it - Autoit is not difficult to learn once you get the hang of how it is structured. And you will find a lot of help here - if you ask the right questions. :shocked:

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