Jump to content

All Constants


=sinister=
 Share

Recommended Posts

I got tired of having to put the Include command in my scripts so many times so I made this. Really simple. Includes all the Constants from your Include folder in your AutoIt folder.

Simply copy and paste the following code into a file called "AllConstants.au3" (Or whatever...)

AllConstants.au3

#Include <GUIConstants.au3>
#Include <AVIConstants.au3>
#Include <ButtonConstants.au3>
#Include <ComboConstants.au3>
#Include <Constants.au3>
#Include <EditConstants.au3>
#Include <FontConstants.au3>
#Include <GDIPlusConstants.au3>
#Include <GUIConstantsEX.au3>
#Include <HeaderConstants.au3>
#Include <ImageListConstants.au3>
#Include <IPAddressConstants.au3>
#Include <ListBoxConstants.au3>
#Include <ListViewConstants.au3>
#Include <MemoryConstants.au3>
#Include <MenuConstants.au3>
#Include <ProgressConstants.au3>
#Include <RebarConstants.au3>
#Include <ScrollBarConstants.au3>
#Include <StaticConstants.au3>
#Include <StatusBarConstants.au3>
#Include <StructureConstants.au3>
#Include <TabConstants.au3>
#Include <TOolbarConstants.au3>
#Include <TreeViewConstants.au3>
#Include <UpDownConstants.au3>
#Include <WindowsConstants.au3>

Example:

#Include <AllConstants.au3>
;blah blah blah...
Link to comment
Share on other sites

I got tired of having to put the Include command in my scripts so many times so I made this. Really simple. Includes all the Constants from your Include folder in your AutoIt folder.

Simply copy and paste the following code into a file called "AllConstants.au3" (Or whatever...)

AllConstants.au3

#Include <GUIConstants.au3>
#Include <AVIConstants.au3>
#Include <ButtonConstants.au3>
#Include <ComboConstants.au3>
#Include <Constants.au3>
#Include <EditConstants.au3>
#Include <FontConstants.au3>
#Include <GDIPlusConstants.au3>
#Include <GUIConstantsEX.au3>
#Include <HeaderConstants.au3>
#Include <ImageListConstants.au3>
#Include <IPAddressConstants.au3>
#Include <ListBoxConstants.au3>
#Include <ListViewConstants.au3>
#Include <MemoryConstants.au3>
#Include <MenuConstants.au3>
#Include <ProgressConstants.au3>
#Include <RebarConstants.au3>
#Include <ScrollBarConstants.au3>
#Include <StaticConstants.au3>
#Include <StatusBarConstants.au3>
#Include <StructureConstants.au3>
#Include <TabConstants.au3>
#Include <TOolbarConstants.au3>
#Include <TreeViewConstants.au3>
#Include <UpDownConstants.au3>
#Include <WindowsConstants.au3>

Example:

#Include <AllConstants.au3>
;blah blah blah...
Thanks but no thanks. Thats over 3200 lines of code and I probably don't need more than 10 of them, and that's before I run my script to replace the constants entirely

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

That gave me an idea.

#Include <File.au3>
Global $sString, $sIncludesDirectory = FileSelectFolder("Choose Includes Dir", @HomeDrive)
If Not $sIncludesDirectory Then
    MsgBox(0, "Error", "No Directory Chosen")
    Exit
EndIf
$azArray = _FileListToArray($sIncludesDirectory, "*.au3")
If Not IsArray($azArray) Then
    MsgBox(0, "Error", "Directory contains no AutoIt3 Script Files")
    Exit
EndIf
For $i = 1 to UBound($azArray) -1
    $sString &="#Include <" & $azArray[$i]&">" & @CRLF
Next
FileWrite($sIncludesDirectory & "\AllConstants.au3", $sString)
MsgBox(0, "Completed", "Completed. AllConstants.au3 Located at " & $sIncludesDirectory)

Run that, choose your Includes directory, and it automatically builds an AllConstants.au3 file with all of the constants in it.

EDIT: But I do agree with GEOSoft that it will just over-inflate your code with things you don't need

Edited by KentonBomb
Link to comment
Share on other sites

... and that's before I run my script to replace the constants entirely

I think something like this needs to be added to SciTE

It'd be so cool to have a hotkey that would just replace all the used constants directly from the editor.

No more #Includes !

Edited by Paulie
Link to comment
Share on other sites

That gave me an idea.

#Include <File.au3>
Global $sString, $sIncludesDirectory = FileSelectFolder("Choose Includes Dir", @HomeDrive)
If Not $sIncludesDirectory Then
    MsgBox(0, "Error", "No Directory Chosen")
    Exit
EndIf
$azArray = _FileListToArray($sIncludesDirectory, "*.au3")
If Not IsArray($azArray) Then
    MsgBox(0, "Error", "Directory contains no AutoIt3 Script Files")
    Exit
EndIf
For $i = 1 to UBound($azArray) -1
    $sString &="#Include <" & $azArray[$i]&">" & @CRLF
Next
FileWrite($sIncludesDirectory & "\AllConstants.au3", $sString)
MsgBox(0, "Completed", "Completed. AllConstants.au3 Located at " & $sIncludesDirectory)

Run that, choose your Includes directory, and it automatically builds an AllConstants.au3 file with all of the constants in it.

EDIT: But I do agree with GEOSoft that it will just over-inflate your code with things you don't need

$azArray = _FileListToArray($sIncludesDirectory, "*constants*.au3")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I got tired of having to put the Include command in my scripts so many times so I made this. Really simple. Includes all the Constants from your Include folder in your AutoIt folder.

Simply copy and paste the following code into a file called "AllConstants.au3" (Or whatever...)

AllConstants.au3

#Include <GUIConstants.au3>
#Include <AVIConstants.au3>
#Include <ButtonConstants.au3>
#Include <ComboConstants.au3>
#Include <Constants.au3>
#Include <EditConstants.au3>
#Include <FontConstants.au3>
#Include <GDIPlusConstants.au3>
#Include <GUIConstantsEX.au3>
#Include <HeaderConstants.au3>
#Include <ImageListConstants.au3>
#Include <IPAddressConstants.au3>
#Include <ListBoxConstants.au3>
#Include <ListViewConstants.au3>
#Include <MemoryConstants.au3>
#Include <MenuConstants.au3>
#Include <ProgressConstants.au3>
#Include <RebarConstants.au3>
#Include <ScrollBarConstants.au3>
#Include <StaticConstants.au3>
#Include <StatusBarConstants.au3>
#Include <StructureConstants.au3>
#Include <TabConstants.au3>
#Include <TOolbarConstants.au3>
#Include <TreeViewConstants.au3>
#Include <UpDownConstants.au3>
#Include <WindowsConstants.au3>

Example:

#Include <AllConstants.au3>
;blah blah blah...
It's not a good idea. I include AllConstants.au3 in one of my script for only some constants...

When the words fail... music speaks.

Link to comment
Share on other sites

the reason for using just the specific includes you need instead of all them is file size.

whats the point of including functions you don't need. :)

I don't like using constants anyway.

Why would I include a file that had

Global Const $Whatever_ThisConstantsNameIs = 1

And have my code read

$a = $Whatever_ThisConstantsNameIs + 1

When I could just use

$a = 1 + 1

or better yet

$a = 2

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Well I only use it when im too lazy to find the specific ones. Then when i'm ready to compile my script I usually find them or just replace the variables with the hexidecimal (Take longer).

Fast when you write a script to do it for you.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I don't like using constants anyway.

Why would I include a file that had

Global Const $Whatever_ThisConstantsNameIs = 1

And have my code read

$a = $Whatever_ThisConstantsNameIs + 1

When I could just use

$a = 1 + 1

or better yet

$a = 2

Because code maintainability starts going down the drain once you start using magic numbers...?

GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, $LVS_SINGLESEL + $LVS_SHOWSELALWAYS + $LVS_SORTASCENDING + $WS_TABSTOP) ; LINE 1
GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, 0x0001001C) ; LINE 2
GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, 65564) ; LINE 3

Would anyone seriously remember (or attempt to guess) what the style is for the listview created in line 2, or worse, line 3?

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Link to comment
Share on other sites

Because code maintainability starts going down the drain once you start using magic numbers...?

GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, $LVS_SINGLESEL + $LVS_SHOWSELALWAYS + $LVS_SORTASCENDING + $WS_TABSTOP) ; LINE 1
GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, 0x0001001C) ; LINE 2
GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, 65564) ; LINE 3

Would anyone seriously remember (or attempt to guess) what the style is for the listview created in line 2, or worse, line 3?

I don't have a problem with it and I wouldn't have to guess at line 2 or line 3 because line 1 would read

GUICtrlCreateListView("Column 1|Column 2", 5, 5, Default, Default, 0x0004 + 0x0008 + 0x0010 + 0x00010000)

after it has been processed by the constants replacer script. And generally replacing the constants is one of the last steps. Besides I find Constants are being seriously abused. What about the people that are #Including a file for the sole reason that they want to use (we see it all the time).

If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit

and $GUI_EVENT_CLOSE is the only constant used in the script.

I would rather just type

If GUIGetMsg = -3 Then Exit

Some of those constant names are longer than the line of code you are going to use them in. The standard Constants are not as bad as some of the constants that people have created in the top of their scripts

Global Const $My_First30CharacterConstant = 0
Global Const $My_Next30CharacterConstant = $My_First30CharacterConstant + 1
Global Const $My_Third30CharacterConstant = $My_Next30CharacterConstant +1
Global Const $My_Fourth30CharacterConstant = $My_Next30CharacterConstant + $My_Third30CharacterConstant

and in the script you have

$A = $My_Next30CharacterConstant + $My_Fourth30CharacterConstant

No thanks, I prefer to type $A = 4.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I think the obfuscater by jos can remove unused variables, and functions.

I don't really like the new layout of the constants, Just the other week I was updating one of my old scripts (from only about a year ago) for the latest Autoit. grrrr! :)

I eventually did what =sinister= did. Just include them all :)

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

Why would you do such a thing when a really fast & simple constants updater is available?

#529242

:)

I would if Scite4AutoIt worked with my install, the latest version is in a non standard location and I have an older version is installed, it ignores my local setup and goes straight for the one thats installed. :/ oh well.

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

I would if Scite4AutoIt worked with my install, the latest version is in a non standard location and I have an older version is installed, it ignores my local setup and goes straight for the one thats installed. :/ oh well.

I just rewrote it to work without Scite. No big problems.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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